]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/lzf: Consider the needed size in reallocation
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 28 May 2020 16:08:57 +0000 (18:08 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 7 Jun 2020 22:21:15 +0000 (00:21 +0200)
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>
libavcodec/lzf.c

index 5b7526ef1854e6c0477a097d15b557cbbe63dbe9..1e3c86c88c3b28044ff11286bde409569669d8cf 100644 (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;