]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/pgxdec: Check depth more completely
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 8 Oct 2020 19:19:14 +0000 (21:19 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 25 Oct 2020 08:47:37 +0000 (09:47 +0100)
Fixes: shift exponent -1 is negative
Fixes: 26107/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGX_fuzzer-5378790047612928
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/pgxdec.c

index 150f8bbf66b479beb436f2963855b950f13f6165..5c735894ab1870543ebc186cfca07016e5ecb433 100644 (file)
@@ -133,14 +133,14 @@ static int pgx_decode_frame(AVCodecContext *avctx, void *data,
     if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
         return ret;
 
-    if (depth <= 8) {
+    if (depth > 0 && depth <= 8) {
         avctx->pix_fmt = AV_PIX_FMT_GRAY8;
         bpp = 8;
-    } else if (depth <= 16) {
+    } else if (depth > 0 && depth <= 16) {
         avctx->pix_fmt = AV_PIX_FMT_GRAY16;
         bpp = 16;
     } else {
-        av_log(avctx, AV_LOG_ERROR, "Maximum depth of 16 bits supported.\n");
+        av_log(avctx, AV_LOG_ERROR, "depth %d is invalid or unsupported.\n", depth);
         return AVERROR_PATCHWELCOME;
     }
     if (bytestream2_get_bytes_left(&g) < width * height * (bpp >> 3))