[FFmpeg-devel] WTV oledate_to_iso8601 overflow

Matej Knopp matej.knopp at inmethod.com
Sun May 8 07:14:35 CEST 2011


Hi,

I'm getting a crash when parsing a WTV file on Windows (mingw32).

The problem is in

static void oledate_to_iso8601(char *buf, int buf_size, int64_t value)

There seem to be two things wrong with it
a) if the time value is very big is  (year 10000) - time_t overflows
and strftime crashes
b) the current implementation seems bit weird, as ole time is time in
days since 30 December 1899

I tried the following implementation and it seems to work

static void oledate_to_iso8601(char *buf, int buf_size, int64_t value)
{
    double days_to_unix = 25569; // difference between start of ole
time and unix time
    time_t max_time = 2147483647;
    int64_t seconds;
    double date;
    time_t t;

    date = av_int2dbl(value);
    date -= days_to_unix; // date is now days since start of unix time
    seconds = 86400 * date;
    if (seconds < max_time)
        t = (time_t)seconds;
    else
        t = max_time;
    strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
}

-Matej


More information about the ffmpeg-devel mailing list