[FFmpeg-devel] [PATCH] indeo3: add out-of-buffer write check

Michael Niedermayer michaelni at gmx.at
Mon May 23 17:08:35 CEST 2011


On Sun, May 22, 2011 at 11:44:37PM +0200, Stefano Sabatini wrote:
> On date Thursday 2011-05-19 08:29:49 +0200, Reimar Döffinger encoded:
> > On 18 May 2011, at 11:38, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:
> > > On date Wednesday 2011-05-18 07:53:31 +0200, Reimar Döffinger encoded:
> > >> 
> > >> On 17 May 2011, at 22:30, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:
> > >> 
> > >>> Prevent out-of-buffer reads. In particular fix smclocki32.avi.1.1
> > >>> crash, fix trac issue #114, roundup issue #1482.
> > >>> ---
> > >>> libavcodec/indeo3.c |    3 +++
> > >>> 1 files changed, 3 insertions(+), 0 deletions(-)
> > >>> 
> > >>> diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c
> > >>> index fb33a7c..37124e4 100644
> > >>> --- a/libavcodec/indeo3.c
> > >>> +++ b/libavcodec/indeo3.c
> > >>> @@ -208,6 +208,7 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
> > >>>    int *width_tbl, width_tbl_arr[10];
> > >>>    const signed char *ref_vectors;
> > >>>    uint8_t *cur_frm_pos, *ref_frm_pos, *cp, *cp2;
> > >>> +    uint8_t *cur_end = cur + width*height + width;
> > >>>    uint32_t *cur_lp, *ref_lp;
> > >>>    const uint32_t *correction_lp[2], *correctionloworder_lp[2], *correctionhighorder_lp[2];
> > >>>    uint8_t *correction_type_sp[2];
> > >>> @@ -354,6 +355,8 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
> > >>>                            k = *buf1++;
> > >>>                            cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2];
> > >>>                            ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2];
> > >>> +                            if ((uint8_t *)cur_lp >= cur_end)
> > >>> +                                break;
> > >> 
> > >> Not sure it matters, but this could still overread with cur_lp == cur_end - 1
> > > 
> > > In practice cur_lp is always a pointer to uint32_t, so is is always
> > > incremented by 4 units. A better solution would involve to fix the
> > > code logic, but that would require a better understanding of the
> > > codec.
> > 
> > I was more thinking of cur_end being odd for example.
> 
> Yes, updated with a more restrictive check (which doesn't seem to
> cause problems to my indeo3 samples).
> 
> I'll apply soon if I see no comments.

only comment from me is that iam in favor of this patch

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

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110523/94d02dc6/attachment.asc>


More information about the ffmpeg-devel mailing list