summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-12-16 02:57:22 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-03-12 00:47:05 +0100
commit127a2902533cfb6d55cf1960d5f184eb4f02211f (patch)
treebaa1393d6662d3120b3bc14822207a31e3e34af0
parent42f8a33c3c396b84932b0badca1cff5d0b6aff5e (diff)
downloadffmpeg-127a2902533cfb6d55cf1960d5f184eb4f02211f.tar.gz
smackerdemuxer: check some values before instead of just after malloc()
Fixes Ticket777 Bug Found by: Diana Elena Muscalu Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit c402c1c976dc5bd63908d1aaff5b60521cbbee92) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/smacker.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index b2c442e2d8..faf85a5261 100644
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -251,6 +251,8 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
memcpy(oldpal, pal, 768);
size = avio_r8(s->pb);
size = size * 4 - 1;
+ if(size + 1 > frame_size)
+ return AVERROR_INVALIDDATA;
frame_size -= size;
frame_size--;
sz = 0;
@@ -292,10 +294,12 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
/* if audio chunks are present, put them to stack and retrieve later */
for(i = 0; i < 7; i++) {
if(flags & 1) {
- int size;
+ unsigned int size;
uint8_t *tmpbuf;
size = avio_rl32(s->pb) - 4;
+ if(size + 4L > frame_size)
+ return AVERROR_INVALIDDATA;
frame_size -= size;
frame_size -= 4;
smk->curstream++;