aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-04-20 22:38:26 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2016-04-27 04:40:12 +0200
commit5127cb2e78c08bddb3f7e6f63e4c960bab465eb9 (patch)
tree95b0bb7b53b00f1fab9ef81dffefc2f4da9f94f3
parent70b3e170f97f4c897f12cdcdaa226d910ea88bb7 (diff)
downloadffmpeg-5127cb2e78c08bddb3f7e6f63e4c960bab465eb9.tar.gz
avcodec/avpacket: Fix off by 5 error
Fixes out of array read Fixes: mozilla bug 1266129 Found-by: Tyson Smith Tested-by: Tyson Smith Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 9f36ea57ae6eefb42432220feab0350494f4144c) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/avpacket.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index ad0a7d795e..35adb86c3d 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -411,10 +411,12 @@ int av_packet_split_side_data(AVPacket *pkt){
p = pkt->data + pkt->size - 8 - 5;
for (i=1; ; i++){
size = AV_RB32(p);
- if (size>INT_MAX || p - pkt->data < size)
+ if (size>INT_MAX - 5 || p - pkt->data < size)
return 0;
if (p[4]&128)
break;
+ if (p - pkt->data < size + 5)
+ return 0;
p-= size+5;
}
@@ -425,7 +427,7 @@ int av_packet_split_side_data(AVPacket *pkt){
p= pkt->data + pkt->size - 8 - 5;
for (i=0; ; i++){
size= AV_RB32(p);
- av_assert0(size<=INT_MAX && p - pkt->data >= size);
+ av_assert0(size<=INT_MAX - 5 && p - pkt->data >= size);
pkt->side_data[i].data = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
pkt->side_data[i].size = size;
pkt->side_data[i].type = p[4]&127;