diff mbox

[FFmpeg-devel,2/5] avcodec/ituh263dec: Check for the bitstream end in ff_h263_decode_mb()

Message ID 20170225200726.7928-2-michael@niedermayer.cc
State Accepted
Commit 0716bcce5bdc6299da2966f34cb62eba3f709be8
Headers show

Commit Message

Michael Niedermayer Feb. 25, 2017, 8:07 p.m. UTC
Fixes invalid shift

Fixes: 670/clusterfuzz-testcase-4852021066727424

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

Comments

Paul B Mahol Feb. 25, 2017, 9:03 p.m. UTC | #1
On 2/25/17, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes invalid shift
>
> Fixes: 670/clusterfuzz-testcase-4852021066727424
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/ituh263dec.c | 3 +++
>  1 file changed, 3 insertions(+)
>

How this fixes invalid shift? Someone could manually add bunch of zero
bits at right place.
Michael Niedermayer Feb. 25, 2017, 9:19 p.m. UTC | #2
On Sat, Feb 25, 2017 at 10:03:58PM +0100, Paul B Mahol wrote:
> On 2/25/17, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > Fixes invalid shift
> >
> > Fixes: 670/clusterfuzz-testcase-4852021066727424
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/ituh263dec.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> 
> How this fixes invalid shift? Someone could manually add bunch of zero

theres a

v >>= 16 - get_bits_left(&s->gb);

[...]
Paul B Mahol Feb. 26, 2017, 9:06 a.m. UTC | #3
On 2/25/17, Michael Niedermayer <michael@niedermayer.cc> wrote:
> On Sat, Feb 25, 2017 at 10:03:58PM +0100, Paul B Mahol wrote:
>> On 2/25/17, Michael Niedermayer <michael@niedermayer.cc> wrote:
>> > Fixes invalid shift
>> >
>> > Fixes: 670/clusterfuzz-testcase-4852021066727424
>> >
>> > Found-by: continuous fuzzing process
>> > https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
>> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
>> > ---
>> >  libavcodec/ituh263dec.c | 3 +++
>> >  1 file changed, 3 insertions(+)
>> >
>>
>> How this fixes invalid shift? Someone could manually add bunch of zero
>
> theres a
>
> v >>= 16 - get_bits_left(&s->gb);

ok then
Michael Niedermayer Feb. 26, 2017, 3:33 p.m. UTC | #4
On Sun, Feb 26, 2017 at 10:06:18AM +0100, Paul B Mahol wrote:
> On 2/25/17, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > On Sat, Feb 25, 2017 at 10:03:58PM +0100, Paul B Mahol wrote:
> >> On 2/25/17, Michael Niedermayer <michael@niedermayer.cc> wrote:
> >> > Fixes invalid shift
> >> >
> >> > Fixes: 670/clusterfuzz-testcase-4852021066727424
> >> >
> >> > Found-by: continuous fuzzing process
> >> > https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
> >> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> >> > ---
> >> >  libavcodec/ituh263dec.c | 3 +++
> >> >  1 file changed, 3 insertions(+)
> >> >
> >>
> >> How this fixes invalid shift? Someone could manually add bunch of zero
> >
> > theres a
> >
> > v >>= 16 - get_bits_left(&s->gb);
> 
> ok then

applied

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 09b6a2f17d..e39338870f 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -962,6 +962,9 @@  intra:
     }
 end:
 
+    if (get_bits_left(&s->gb) < 0)
+        return AVERROR_INVALIDDATA;
+
         /* per-MB end of slice check */
     {
         int v= show_bits(&s->gb, 16);