diff mbox series

[FFmpeg-devel,2/2] avcodec/tiff: Check bpp/bppcount for 0

Message ID 20200806211816.9582-2-michael@niedermayer.cc
State Accepted
Headers show
Series [FFmpeg-devel,1/2] avcodec/snowdec: Sanity check hcoeff | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Michael Niedermayer Aug. 6, 2020, 9:18 p.m. UTC
Fixes: division by zero
Fixes: 24253/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6250318007107584

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/tiff.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Andreas Rheinhardt Aug. 6, 2020, 9:31 p.m. UTC | #1
Michael Niedermayer:
> Fixes: division by zero
> Fixes: 24253/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6250318007107584
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/tiff.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
> index 18b327e800..5c748e9650 100644
> --- a/libavcodec/tiff.c
> +++ b/libavcodec/tiff.c
> @@ -1290,7 +1290,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
>          s->height = value;
>          break;
>      case TIFF_BPP:
> -        if (count > 5U) {
> +        if (count > 5 || count <= 0) {
>              av_log(s->avctx, AV_LOG_ERROR,
>                     "This format is not supported (bpp=%d, %d components)\n",
>                     value, count);
> @@ -1321,7 +1321,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
>                     "Samples per pixel requires a single value, many provided\n");
>              return AVERROR_INVALIDDATA;
>          }
> -        if (value > 5U) {
> +        if (value > 5 || value <= 0) {
>              av_log(s->avctx, AV_LOG_ERROR,
>                     "Samples per pixel %d is too large\n", value);

How about changing this to "Invalid samples per pixel %d\n"?

>              return AVERROR_INVALIDDATA;
>
Michael Niedermayer Aug. 7, 2020, 10:04 a.m. UTC | #2
On Thu, Aug 06, 2020 at 11:31:03PM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: division by zero
> > Fixes: 24253/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6250318007107584
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/tiff.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
> > index 18b327e800..5c748e9650 100644
> > --- a/libavcodec/tiff.c
> > +++ b/libavcodec/tiff.c
> > @@ -1290,7 +1290,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
> >          s->height = value;
> >          break;
> >      case TIFF_BPP:
> > -        if (count > 5U) {
> > +        if (count > 5 || count <= 0) {
> >              av_log(s->avctx, AV_LOG_ERROR,
> >                     "This format is not supported (bpp=%d, %d components)\n",
> >                     value, count);
> > @@ -1321,7 +1321,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
> >                     "Samples per pixel requires a single value, many provided\n");
> >              return AVERROR_INVALIDDATA;
> >          }
> > -        if (value > 5U) {
> > +        if (value > 5 || value <= 0) {
> >              av_log(s->avctx, AV_LOG_ERROR,
> >                     "Samples per pixel %d is too large\n", value);
> 
> How about changing this to "Invalid samples per pixel %d\n"?

will apply with this change

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 18b327e800..5c748e9650 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1290,7 +1290,7 @@  static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
         s->height = value;
         break;
     case TIFF_BPP:
-        if (count > 5U) {
+        if (count > 5 || count <= 0) {
             av_log(s->avctx, AV_LOG_ERROR,
                    "This format is not supported (bpp=%d, %d components)\n",
                    value, count);
@@ -1321,7 +1321,7 @@  static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
                    "Samples per pixel requires a single value, many provided\n");
             return AVERROR_INVALIDDATA;
         }
-        if (value > 5U) {
+        if (value > 5 || value <= 0) {
             av_log(s->avctx, AV_LOG_ERROR,
                    "Samples per pixel %d is too large\n", value);
             return AVERROR_INVALIDDATA;