diff mbox series

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

Message ID 20220719233419.17185-2-michael@niedermayer.cc
State Accepted
Commit 3c43a7a354e8ad9e6a270b592cd7c5c1f3f62110
Headers show
Series [FFmpeg-devel,1/2] avformat/mov: Check for EOF in mov_read_iloc() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer July 19, 2022, 11:34 p.m. UTC
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@niedermayer.cc>
---
 libavcodec/hdrdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paul B Mahol July 20, 2022, 6:55 a.m. UTC | #1
lgtm
Michael Niedermayer July 20, 2022, 2:28 p.m. UTC | #2
On Wed, Jul 20, 2022 at 08:55:45AM +0200, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]
diff mbox series

Patch

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) {