[FFmpeg-devel] [PATCH] Fix possible SIGFPEs with bad mov timings. Based on chromium patch 35_mov_bad_timings.patch

Baptiste Coudurier baptiste.coudurier
Thu Nov 19 07:45:52 CET 2009


On 11/18/09 10:18 PM, Albert J. Wong (???) wrote:
> This patch is based off of the chromium patch:
>
>
> http://src.chromium.org/viewvc/chrome/trunk/deps/third_party/ffmpeg/patches/to_upstream/35_mov_bad_timings.patch?view=log
>
> It adds checks to ensure that the time_scale in the MOVContext or the
> MOVStreamContext are not 0.  If time_scale is allowed to be 0, then later in
> the code path, it is possible for an av_rescale to be called with 0 as the
> denominator producing a SIGFPE.
>
> This patch was tested against r20546 of mainline, and passed the regression
> test suite run on an argumentless ./configure.
>
> -Albert
>
>
> 35_mov_bad_timings_upstream.patch
>
>
> diff --git libavformat/mov.c libavformat/mov.c
> index 6a8c149..e3e3e01 100644
> --- libavformat/mov.c
> +++ libavformat/mov.c
> @@ -1624,11 +1624,11 @@ static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
>           return 0;
>       }
>
> -    if (!sc->time_scale) {
> +    if (c->time_scale<= 0)
> +      c->time_scale = 1;
> +    if (sc->time_scale<=0) {
>           av_log(c->fc, AV_LOG_WARNING, "stream %d, timescale not set\n", st->index);
>           sc->time_scale = c->time_scale;
> -        if (!sc->time_scale)
> -            sc->time_scale = 1;
>       }
>
>       av_set_pts_info(st, 64, 1, sc->time_scale);

I think the patch is wrong to check < 0 because according to 
specifications time scale is unsigned. However, AVRational is signed 
even though av_set_pts_info takes unsigned as arguments.

I don't like the < 0 check, but I guess we don't have much choice here.

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



More information about the ffmpeg-devel mailing list