[FFmpeg-devel] [PATCH 3/3] lavf/mxfdec: validate month/day before date formatting

Hendrik Leppkes h.leppkes at gmail.com
Sat Apr 13 15:45:57 CEST 2013


Some implementations of strftime do not like invalid values for
month/day, so ensure it doesn't happen.
---
 libavformat/mxfdec.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 6306756..aa29cd8 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1668,6 +1668,10 @@ static int mxf_timestamp_to_str(uint64_t timestamp, char **str)
     time.tm_min  = (timestamp >> 16 & 0xF);
     time.tm_sec  = (timestamp >> 8  & 0xF);
 
+    /* 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);
-- 
1.8.1.msysgit.1



More information about the ffmpeg-devel mailing list