From: Michael Niedermayer Date: Sun, 26 Oct 2014 01:06:40 +0000 (+0100) Subject: Merge commit '9dcf2397219ca796f0fafce2a703770d6fd09920' X-Git-Tag: n2.6-dev~783 X-Git-Url: http://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff_plain/3b709fd912749d7731fa954cfb3aedd18d8a666a Merge commit '9dcf2397219ca796f0fafce2a703770d6fd09920' * commit '9dcf2397219ca796f0fafce2a703770d6fd09920': lavf: Check the return value of strftime Conflicts: libavformat/wtvdec.c Merged-by: Michael Niedermayer --- 3b709fd912749d7731fa954cfb3aedd18d8a666a diff --cc libavformat/mov.c index f81b109,a5b39f2..bb18588 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@@ -810,14 -740,11 +810,14 @@@ static void mov_metadata_creation_time( char buffer[32]; if (time) { struct tm *ptm; - time -= 2082844800; /* seconds between 1904-01-01 and Epoch */ - ptm = gmtime(&time); + time_t timet; + if(time >= 2082844800) + time -= 2082844800; /* seconds between 1904-01-01 and Epoch */ + timet = time; + ptm = gmtime(&timet); if (!ptm) return; - strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ptm); - av_dict_set(metadata, "creation_time", buffer, 0); + if (strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ptm)) + av_dict_set(metadata, "creation_time", buffer, 0); } } diff --cc libavformat/wtvdec.c index 5012890,90984cf..de3c931 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@@ -387,10 -429,11 +387,11 @@@ static int filetime_to_iso8601(char *bu { time_t t = (value / 10000000LL) - 11644473600LL; struct tm *tm = gmtime(&t); - if (tm) { - if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm)) - buf[0] = '\0'; - } else - buf[0] = '\0'; + if (!tm) + return -1; - strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm); ++ if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm)) ++ return -1; + return 0; } /** @@@ -401,24 -443,25 +402,26 @@@ static int crazytime_to_iso8601(char *b { time_t t = (value / 10000000LL) - 719162LL*86400LL; struct tm *tm = gmtime(&t); - if (tm) { - if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm)) - buf[0] = '\0'; - } else - buf[0] = '\0'; + if (!tm) + return -1; - strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm); ++ if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm)) ++ return -1; + return 0; } /** * Convert OLE DATE to ISO-8601 string + * @return <0 on error */ -static void oledate_to_iso8601(char *buf, int buf_size, int64_t value) +static int oledate_to_iso8601(char *buf, int buf_size, int64_t value) { - time_t t = 631112400LL + 86400*av_int2double(value); - struct tm *tm = gmtime(&t); - if (tm) { - if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm)) - buf[0] = '\0'; - } else - buf[0] = '\0'; + time_t t = (av_int2double(value) - 25569.0) * 86400; + struct tm *tm= gmtime(&t); + if (!tm) + return -1; - strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm); ++ if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm)) ++ return -1; + return 0; } static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length)