[FFmpeg-devel] [PATCH] avcodec/h263dec: Check against previous dimensions instead of coded

Michael Niedermayer michael at niedermayer.cc
Sat Feb 1 00:10:40 EET 2025


On Thu, Jan 30, 2025 at 09:15:23AM +0100, Kacper Michajlow wrote:
> On Thu, 30 Jan 2025 at 02:57, Michael Niedermayer
> <michael at niedermayer.cc> wrote:
> >
> > Fixes: out of array access
> > Fixes: crash-a41ef3db699013f669b076f02f36942925f5a98c
> >
> > Found-by: Kacper Michajlow <kasper93 at gmail.com>
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > ---
> >  libavcodec/h263dec.c | 13 +++++++++----
> >  1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
> > index 0c23012584e..5eefdc4602b 100644
> > --- a/libavcodec/h263dec.c
> > +++ b/libavcodec/h263dec.c
> > @@ -431,6 +431,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict,
> >      MpegEncContext *s  = avctx->priv_data;
> >      int ret;
> >      int slice_ret = 0;
> > +    int bak_width, bak_height;
> >
> >      /* no supplementary picture */
> >      if (buf_size == 0) {
> > @@ -482,6 +483,9 @@ retry:
> >      if (ret < 0)
> >          return ret;
> >
> > +    bak_width  = s->width;
> > +    bak_height = s->height;
> > +
> >      /* let's go :-) */
> >      if (CONFIG_WMV2_DECODER && s->msmpeg4_version == MSMP4_WMV2) {
> >          ret = ff_wmv2_decode_picture_header(s);
> > @@ -501,11 +505,12 @@ retry:
> >      }
> >
> >      if (ret < 0 || ret == FRAME_SKIPPED) {
> > -        if (   s->width  != avctx->coded_width
> > -            || s->height != avctx->coded_height) {
> > +        if (   s->width  != bak_width
> > +            || s->height != bak_height) {
> >                  av_log(s->avctx, AV_LOG_WARNING, "Reverting picture dimensions change due to header decoding failure\n");
> > -                s->width = avctx->coded_width;
> > -                s->height= avctx->coded_height;
> > +                s->width = bak_width;
> > +                s->height= bak_height;
> > +
> >          }
> >      }
> >      if (ret == FRAME_SKIPPED)
> > --
> > 2.48.1
> >
> 
> Works for me. Thanks.

will apply

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Some people wanted to paint the bikeshed green, some blue and some pink.
People argued and fought, when they finally agreed, only rust was left.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250131/669cf70c/attachment.sig>


More information about the ffmpeg-devel mailing list