summaryrefslogtreecommitdiff
path: root/libavformat/wtv.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2014-10-24 10:43:20 +0300
committerMartin Storsjö <martin@martin.st>2014-10-26 00:14:54 +0300
commit9dcf2397219ca796f0fafce2a703770d6fd09920 (patch)
treea7a43f39be7fa2e3cfd09c890a40373f0742f154 /libavformat/wtv.c
parent851ace79a307bea54b44bd6f7ecd3b7861c28ec6 (diff)
lavf: Check the return value of strftime
If the buffer provided to strftime is too small, the buffer contents are indeterminate - it does not guarantee actually null terminating the buffer. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/wtv.c')
-rw-r--r--libavformat/wtv.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/libavformat/wtv.c b/libavformat/wtv.c
index fa864e840a..90984cfda0 100644
--- a/libavformat/wtv.c
+++ b/libavformat/wtv.c
@@ -429,9 +429,10 @@ static void filetime_to_iso8601(char *buf, int buf_size, int64_t value)
{
time_t t = (value / 10000000LL) - 11644473600LL;
struct tm *tm = gmtime(&t);
- if (tm)
- strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm);
- else
+ if (tm) {
+ if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
+ buf[0] = '\0';
+ } else
buf[0] = '\0';
}
@@ -442,9 +443,10 @@ static void crazytime_to_iso8601(char *buf, int buf_size, int64_t value)
{
time_t t = (value / 10000000LL) - 719162LL*86400LL;
struct tm *tm = gmtime(&t);
- if (tm)
- strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm);
- else
+ if (tm) {
+ if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
+ buf[0] = '\0';
+ } else
buf[0] = '\0';
}
@@ -455,9 +457,10 @@ static void 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)
- strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm);
- else
+ if (tm) {
+ if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
+ buf[0] = '\0';
+ } else
buf[0] = '\0';
}