diff mbox

[FFmpeg-devel,1/3] avcodec/eatgv: Check remaining size after the keyframe header

Message ID 20190728230931.23214-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer July 28, 2019, 11:09 p.m. UTC
The minimal size which unpack() will not fail on is 5 bytes
Fixes: Timeout (14sec -> 77ms) (testcase 15508)
Fixes: 15508/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATGV_fuzzer-5700053513011200
Fixes: 15996/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATGV_fuzzer-5751353223151616

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/eatgv.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Paul B Mahol July 29, 2019, 6:48 a.m. UTC | #1
LGTM

On Mon, Jul 29, 2019 at 1:11 AM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> The minimal size which unpack() will not fail on is 5 bytes
> Fixes: Timeout (14sec -> 77ms) (testcase 15508)
> Fixes:
> 15508/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATGV_fuzzer-5700053513011200
> Fixes:
> 15996/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATGV_fuzzer-5751353223151616
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by
> <https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by>:
> Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/eatgv.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c
> index 93e291f053..77b5da1f14 100644
> --- a/libavcodec/eatgv.c
> +++ b/libavcodec/eatgv.c
> @@ -300,6 +300,10 @@ static int tgv_decode_frame(AVCodecContext *avctx,
>              s->palette[i] = 0xFFU << 24 | AV_RB24(buf);
>              buf += 3;
>          }
> +        if (buf_end - buf < 5) {
> +            av_log(avctx, AV_LOG_WARNING, "packed data truncated\n");
> +            return AVERROR_INVALIDDATA;
> +        }
>      }
>
>      if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
> --
> 2.22.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Paul B Mahol July 29, 2019, 6:49 a.m. UTC | #2
Actually remove log message completely. It is invalid because it is warning
while you return error immediately.

On Mon, Jul 29, 2019 at 8:48 AM Paul B Mahol <onemda@gmail.com> wrote:

> LGTM
>
> On Mon, Jul 29, 2019 at 1:11 AM Michael Niedermayer <michael@niedermayer.cc>
> wrote:
>
>> The minimal size which unpack() will not fail on is 5 bytes
>> Fixes: Timeout (14sec -> 77ms) (testcase 15508)
>> Fixes:
>> 15508/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATGV_fuzzer-5700053513011200
>> Fixes:
>> 15996/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATGV_fuzzer-5751353223151616
>>
>> Found-by: continuous fuzzing process
>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>> Signed-off-by
>> <https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by>:
>> Michael Niedermayer <michael@niedermayer.cc>
>> ---
>>  libavcodec/eatgv.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c
>> index 93e291f053..77b5da1f14 100644
>> --- a/libavcodec/eatgv.c
>> +++ b/libavcodec/eatgv.c
>> @@ -300,6 +300,10 @@ static int tgv_decode_frame(AVCodecContext *avctx,
>>              s->palette[i] = 0xFFU << 24 | AV_RB24(buf);
>>              buf += 3;
>>          }
>> +        if (buf_end - buf < 5) {
>> +            av_log(avctx, AV_LOG_WARNING, "packed data truncated\n");
>> +            return AVERROR_INVALIDDATA;
>> +        }
>>      }
>>
>>      if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
>> --
>> 2.22.0
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
>
Michael Niedermayer July 29, 2019, 5:09 p.m. UTC | #3
On Mon, Jul 29, 2019 at 08:49:40AM +0200, Paul B Mahol wrote:
> Actually remove log message completely. 

ok, will apply with that change


> It is invalid because it is warning
> while you return error immediately.

Thats true for most of the error messages in the file.

Thanks

[...]
diff mbox

Patch

diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c
index 93e291f053..77b5da1f14 100644
--- a/libavcodec/eatgv.c
+++ b/libavcodec/eatgv.c
@@ -300,6 +300,10 @@  static int tgv_decode_frame(AVCodecContext *avctx,
             s->palette[i] = 0xFFU << 24 | AV_RB24(buf);
             buf += 3;
         }
+        if (buf_end - buf < 5) {
+            av_log(avctx, AV_LOG_WARNING, "packed data truncated\n");
+            return AVERROR_INVALIDDATA;
+        }
     }
 
     if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)