diff mbox

[FFmpeg-devel,1/3] avcodec/shorten: Fix bitstream end check in read_header()

Message ID 20180915000822.1017-1-michael@niedermayer.cc
State Accepted
Commit 28b80c2d52d82eb4f73af5f818dab60946bcf299
Headers show

Commit Message

Michael Niedermayer Sept. 15, 2018, 12:08 a.m. UTC
Fixes: Timeout
Fixes: 9961/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-5687856176562176

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

Comments

Paul B Mahol Sept. 15, 2018, 8:51 a.m. UTC | #1
On 9/15/18, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: Timeout
> Fixes:
> 9961/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-5687856176562176
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/shorten.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

lgtm
Michael Niedermayer Sept. 15, 2018, 1:06 p.m. UTC | #2
On Sat, Sep 15, 2018 at 10:51:45AM +0200, Paul B Mahol wrote:
> On 9/15/18, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > Fixes: Timeout
> > Fixes:
> > 9961/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-5687856176562176
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/shorten.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> lgtm

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index 1ffb7d8d79..4b45e6d6dc 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -456,7 +456,7 @@  static int read_header(ShortenContext *s)
         }
 
         skip_bytes = get_uint(s, NSKIPSIZE);
-        if ((unsigned)skip_bytes > get_bits_left(&s->gb)/8) {
+        if ((unsigned)skip_bytes > FFMAX(get_bits_left(&s->gb), 0)/8) {
             av_log(s->avctx, AV_LOG_ERROR, "invalid skip_bytes: %d\n", skip_bytes);
             return AVERROR_INVALIDDATA;
         }