lavf/mxfdec: validate month/day before date formatting
authorHendrik Leppkes <h.leppkes@gmail.com>
Sat, 13 Apr 2013 13:45:57 +0000 (15:45 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 13 Apr 2013 16:07:08 +0000 (18:07 +0200)
Some implementations of strftime do not like invalid values for
month/day, so ensure it doesn't happen.

Reviewed-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/mxfdec.c

index 4ceaaee..33e1eb4 100644 (file)
@@ -1668,6 +1668,10 @@ static int mxf_timestamp_to_str(uint64_t timestamp, char **str)
     time.tm_min  = (timestamp >> 16 & 0xFF);
     time.tm_sec  = (timestamp >> 8  & 0xFF);
 
+    /* ensure month/day are valid */
+    time.tm_mon  = FFMAX(time.tm_mon, 0);
+    time.tm_mday = FFMAX(time.tm_mday, 1);
+
     *str = av_mallocz(32);
     if (!*str)
         return AVERROR(ENOMEM);