summaryrefslogtreecommitdiff
path: root/libavformat/wtv.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/wtv.c')
-rw-r--r--libavformat/wtv.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavformat/wtv.c b/libavformat/wtv.c
index b0039051f9..50997398a5 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;
}