[FFmpeg-devel] [PATCH 2/2] avcodec/hdrdec: lines can be empty

Michael Niedermayer michael at niedermayer.cc
Wed Jul 20 02:34:19 EEST 2022


Fixes: infinite loop
Fixes: 49223/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HDR_fuzzer-6603308596330496

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

diff --git a/libavcodec/hdrdec.c b/libavcodec/hdrdec.c
index 458215c6ac..29e87057fa 100644
--- a/libavcodec/hdrdec.c
+++ b/libavcodec/hdrdec.c
@@ -107,7 +107,7 @@ static int hdr_decode_frame(AVCodecContext *avctx, AVFrame *p,
         hdr_get_line(&gb, line, sizeof(line));
         if (sscanf(line, "PIXASPECT=%f\n", &sar) == 1)
             avctx->sample_aspect_ratio = p->sample_aspect_ratio = av_inv_q(av_d2q(sar, 4096));
-    } while (line[0] != '\n');
+    } while (line[0] != '\n' && line[0]);
 
     hdr_get_line(&gb, line, sizeof(line));
     if (sscanf(line, "-Y %d +X %d\n", &height, &width) == 2) {
-- 
2.17.1



More information about the ffmpeg-devel mailing list