summaryrefslogtreecommitdiffstats
path: root/libavformat/wtvdec.c
diff options
context:
space:
mode:
authorPeter Ross <pross@xvid.org>2011-05-08 20:13:59 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-05-09 02:25:40 +0200
commit8acab7ae5bbcb589c556425453ac3d851d35021f (patch)
treeac8a7870f34af4ce8bed7415ae5152fbdb5a854c /libavformat/wtvdec.c
parent3dd779eb0affdd6d597291a5cc6215a138f71495 (diff)
downloadffmpeg-streaming-8acab7ae5bbcb589c556425453ac3d851d35021f.zip
ffmpeg-streaming-8acab7ae5bbcb589c556425453ac3d851d35021f.tar.gz
wtv: detect ole date overflow
Diffstat (limited to 'libavformat/wtvdec.c')
-rw-r--r--libavformat/wtvdec.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index c775dfb..19d5b54 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -398,11 +398,16 @@ static void crazytime_to_iso8601(char *buf, int buf_size, int64_t value)
/**
* 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);
- 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)
@@ -463,9 +468,12 @@ static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int ty
else if (!strcmp(key, "WM/WMRVEncodeTime") ||
!strcmp(key, "WM/WMRVEndTime"))
crazytime_to_iso8601(buf, buf_size, num);
- else if (!strcmp(key, "WM/WMRVExpirationDate"))
- oledate_to_iso8601(buf, buf_size, num);
- else if (!strcmp(key, "WM/WMRVBitrate"))
+ else if (!strcmp(key, "WM/WMRVExpirationDate")) {
+ if (oledate_to_iso8601(buf, buf_size, num) < 0 ) {
+ av_free(buf);
+ return;
+ }
+ } else if (!strcmp(key, "WM/WMRVBitrate"))
snprintf(buf, buf_size, "%f", av_int2dbl(num));
else
snprintf(buf, buf_size, "%"PRIi64, num);
OpenPOWER on IntegriCloud