Browse Source

avcodec/lzf: Consider the needed size in reallocation

Fixes: NULL pointer dereference
Fixes: 22381/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NOTCHLC_fuzzer-5659879921680384.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 292b9b93a5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n4.2.4
Michael Niedermayer 5 years ago
parent
commit
a497d3de31
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      libavcodec/lzf.c

+ 2
- 2
libavcodec/lzf.c View File

@@ -49,7 +49,7 @@ int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size)
if (s < LZF_LITERAL_MAX) {
s++;
if (s > *size - len) {
*size += *size /2;
*size += s + *size /2;
ret = av_reallocp(buf, *size);
if (ret < 0)
return ret;
@@ -72,7 +72,7 @@ int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size)
return AVERROR_INVALIDDATA;

if (l > *size - len) {
*size += *size / 2;
*size += l + *size / 2;
ret = av_reallocp(buf, *size);
if (ret < 0)
return ret;


Loading…
Cancel
Save