Commit 8acab7ae authored by Peter Ross's avatar Peter Ross Committed by Michael Niedermayer

wtv: detect ole date overflow

parent 3dd779eb
...@@ -398,11 +398,16 @@ static void crazytime_to_iso8601(char *buf, int buf_size, int64_t value) ...@@ -398,11 +398,16 @@ static void crazytime_to_iso8601(char *buf, int buf_size, int64_t value)
/** /**
* Convert OLE DATE to ISO-8601 string * 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_int2dbl(value); time_t t = 631112400LL + 86400*av_int2dbl(value);
strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t)); struct tm result;
if (!gmtime_r(&t, &result))
return -1;
strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", &result);
return 0;
} }
static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length) static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length)
...@@ -463,9 +468,12 @@ static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int ty ...@@ -463,9 +468,12 @@ static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int ty
else if (!strcmp(key, "WM/WMRVEncodeTime") || else if (!strcmp(key, "WM/WMRVEncodeTime") ||
!strcmp(key, "WM/WMRVEndTime")) !strcmp(key, "WM/WMRVEndTime"))
crazytime_to_iso8601(buf, buf_size, num); crazytime_to_iso8601(buf, buf_size, num);
else if (!strcmp(key, "WM/WMRVExpirationDate")) else if (!strcmp(key, "WM/WMRVExpirationDate")) {
oledate_to_iso8601(buf, buf_size, num); if (oledate_to_iso8601(buf, buf_size, num) < 0 ) {
else if (!strcmp(key, "WM/WMRVBitrate")) av_free(buf);
return;
}
} else if (!strcmp(key, "WM/WMRVBitrate"))
snprintf(buf, buf_size, "%f", av_int2dbl(num)); snprintf(buf, buf_size, "%f", av_int2dbl(num));
else else
snprintf(buf, buf_size, "%"PRIi64, num); snprintf(buf, buf_size, "%"PRIi64, num);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment