[FFmpeg-cvslog] wtv: Add more sanity checks for a length read from the file
Martin Storsjö
git at videolan.org
Fri Sep 20 14:56:36 CEST 2013
ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Thu Sep 19 16:55:13 2013 +0300| [83c285f88016b087c2f0f4b9ef356ad8ef12d947] | committer: Martin Storsjö
wtv: Add more sanity checks for a length read from the file
Also make sure the existing length check can't overflow.
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable at libav.org
Signed-off-by: Martin Storsjö <martin at martin.st>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=83c285f88016b087c2f0f4b9ef356ad8ef12d947
---
libavformat/wtv.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/libavformat/wtv.c b/libavformat/wtv.c
index b003905..5099739 100644
--- a/libavformat/wtv.c
+++ b/libavformat/wtv.c
@@ -269,7 +269,12 @@ static AVIOContext * wtvfile_open2(AVFormatContext *s, const uint8_t *buf, int b
dir_length = AV_RL16(buf + 16);
file_length = AV_RL64(buf + 24);
name_size = 2 * AV_RL32(buf + 32);
- if (buf + 48 + name_size > buf_end) {
+ if (name_size < 0) {
+ av_log(s, AV_LOG_ERROR,
+ "bad filename length, remaining directory entries ignored\n");
+ break;
+ }
+ if (48 + name_size > buf_end - buf) {
av_log(s, AV_LOG_ERROR, "filename exceeds buffer size; remaining directory entries ignored\n");
break;
}
More information about the ffmpeg-cvslog
mailing list