[FFmpeg-devel] [PATCH 3/4] avcodec/h264_parser: Fix nalsize check
Michael Niedermayer
michael at niedermayer.cc
Sun Sep 5 22:24:17 EEST 2021
Fixes: Assertion failure
Fixes: 37463/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-4914693494931456
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/h264_parser.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 01ea016409..47cc1d5c78 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -87,7 +87,7 @@ static int h264_find_frame_end(H264ParseContext *p, const uint8_t *buf,
i = next_avc;
for (j = 0; j < p->nal_length_size; j++)
nalsize = (nalsize << 8) | buf[i++];
- if (!nalsize || nalsize > buf_size - i) {
+ if (!nalsize || i > buf_size || nalsize > buf_size - i) {
av_log(logctx, AV_LOG_ERROR, "AVC-parser: nal size %"PRIu32" "
"remaining %d\n", nalsize, buf_size - i);
return buf_size;
--
2.17.1
More information about the ffmpeg-devel
mailing list