[FFmpeg-devel] [PATCH] Fix DV uninitialized reads

Baptiste Coudurier baptiste.coudurier
Tue Sep 22 09:19:29 CEST 2009


Hi Reimar,

On 09/21/2009 05:40 AM, Reimar D?ffinger wrote:
> Hello,
> I think this fixes the uninitialized data in the DV encoder that causes
> sporadic "make test" failures, at least valgrind complains no longer.
> Quick measurements with "time" indicate a slowdown by about 0.8%.
> regression test values for the encoded files changes (memset to 0
> instead of 0xff might avoid that though), but the decoded data
> stays the same - so at least for the cases "make test" covers it is
> correct.

I assume 0xff is correct according to specs, right ?

> Index: libavcodec/dv.c
> ===================================================================
> --- libavcodec/dv.c     (revision 19948)
> +++ libavcodec/dv.c     (working copy)
> @@ -1102,8 +1102,14 @@
>               av_log(NULL, AV_LOG_ERROR, "ac bitstream overflow\n");
>       }
>
> -    for (j=0; j<5*s->sys->bpm; j++)
> +    for (j=0; j<5*s->sys->bpm; j++) {
> +       int pos, size;
>          flush_put_bits(&pbs[j]);
> +       pos = put_bits_count(&pbs[j])>>  3;
> +       size = pbs[j].size_in_bits>>  3;

Maybe s->sys->block_sizes[j] makes more sense ?

> +       if (pos<  size)
> +           memset(pbs[j].buf + pos, 0xff, size - pos);

Is it worth to check for pos < size ?

[...]

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list