[FFmpeg-cvslog] avcodec/shorten: Clear the additionally allocated space on realloc
Michael Niedermayer
git at videolan.org
Mon Jul 28 20:06:24 EEST 2025
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Wed Jul 23 21:13:33 2025 +0200| [909229b880d5f2c2277ab10915954b18d5162322] | committer: Michael Niedermayer
avcodec/shorten: Clear the additionally allocated space on realloc
Fixes: use of uninitialized memory
Fixes: 421954767/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-515682786246656
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=909229b880d5f2c2277ab10915954b18d5162322
---
libavcodec/shorten.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index ad2e7588d6..bed9293680 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -584,7 +584,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, AVFrame *frame,
if (avpkt->size) {
int max_framesize = s->blocksize * s->channels * 8;
void *tmp_ptr;
-
+ unsigned old_allocated_bitstream_size = s->allocated_bitstream_size;
tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size,
max_framesize + AV_INPUT_BUFFER_PADDING_SIZE);
if (!tmp_ptr) {
@@ -592,9 +592,8 @@ static int shorten_decode_frame(AVCodecContext *avctx, AVFrame *frame,
return AVERROR(ENOMEM);
}
s->bitstream = tmp_ptr;
- if (max_framesize > s->max_framesize)
- memset(s->bitstream + s->max_framesize, 0, (max_framesize - s->max_framesize) +
- AV_INPUT_BUFFER_PADDING_SIZE);
+ if (s->allocated_bitstream_size > old_allocated_bitstream_size)
+ memset(s->bitstream + old_allocated_bitstream_size, 0, s->allocated_bitstream_size - old_allocated_bitstream_size);
s->max_framesize = FFMAX(s->max_framesize, max_framesize);
*got_frame_ptr = 0;
goto finish_frame;
More information about the ffmpeg-cvslog
mailing list