[FFmpeg-cvslog] avcodec/h2645_parse: Reduce the initial skipped_bytes_pos size with small inputs

Michael Niedermayer git at videolan.org
Mon Mar 1 21:20:23 EET 2021


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sat Dec 12 16:36:04 2020 +0100| [ee50f727158095f77a4fdadd572e3bd59ac101f2] | committer: Michael Niedermayer

avcodec/h2645_parse: Reduce the initial skipped_bytes_pos size with small inputs

Fixes: OOM
Fixes: 23817/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-6300869057576960
Fixes: 28055/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5706035297517568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ee50f727158095f77a4fdadd572e3bd59ac101f2
---

 libavcodec/h2645_parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index a36ef4f5a0..6fbe97ad4a 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -467,7 +467,7 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
             memset(pkt->nals + pkt->nals_allocated, 0, sizeof(*pkt->nals));
 
             nal = &pkt->nals[pkt->nb_nals];
-            nal->skipped_bytes_pos_size = 1024; // initial buffer size
+            nal->skipped_bytes_pos_size = FFMIN(1024, extract_length/3+1); // initial buffer size
             nal->skipped_bytes_pos = av_malloc_array(nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos));
             if (!nal->skipped_bytes_pos)
                 return AVERROR(ENOMEM);



More information about the ffmpeg-cvslog mailing list