diff options
author | Martin Storsjö <martin@martin.st> | 2014-03-09 22:44:10 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2014-03-10 11:11:08 +0200 |
commit | 8cafeb8bca5d079041739dbd72ccec0ead138eaf (patch) | |
tree | f1c913ad0561f30dc2fa2a06c574f1eed2c904a8 | |
parent | 558b20d729bc296d8e6a69f03cd509ad26a4827d (diff) | |
download | ffmpeg-8cafeb8bca5d079041739dbd72ccec0ead138eaf.tar.gz |
mxfdec: Validate parameters to strftime
The MSVCRT version of strftime calls the invalid parameter handler
if the struct values in struct tm are invalid. In case no invalid
parameter handler is set for the process, the process is aborted.
This fixes fate failures on MSVC builds since 570af382.
Based on a patch by Hendrik Leppkes.
Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r-- | libavformat/mxfdec.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 27f996fa82..d6e2155887 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1669,6 +1669,15 @@ static int mxf_timestamp_to_str(uint64_t timestamp, char **str) time.tm_min = (timestamp >> 16 & 0xFF); time.tm_sec = (timestamp >> 8 & 0xFF); + /* msvcrt versions of strftime calls the invalid parameter handler + * (aborting the process if one isn't set) if the parameters are out + * of range. */ + time.tm_mon = av_clip(time.tm_mon, 0, 11); + time.tm_mday = av_clip(time.tm_mday, 1, 31); + time.tm_hour = av_clip(time.tm_hour, 0, 23); + time.tm_min = av_clip(time.tm_min, 0, 59); + time.tm_sec = av_clip(time.tm_sec, 0, 59); + *str = av_mallocz(32); if (!*str) return AVERROR(ENOMEM); |