[FFmpeg-cvslog] avcodec/avpacket: Fix off by 5 error

Michael Niedermayer git at videolan.org
Sun May 1 05:13:51 CEST 2016


ffmpeg | branch: release/2.5 | Michael Niedermayer <michael at niedermayer.cc> | Wed Apr 20 22:38:26 2016 +0200| [9ae85f1468f41a9d56629e401c72ac7f342ca414] | committer: Michael Niedermayer

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 at niedermayer.cc>
(cherry picked from commit 9f36ea57ae6eefb42432220feab0350494f4144c)

Conflicts:

	libavcodec/avpacket.c

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9ae85f1468f41a9d56629e401c72ac7f342ca414
---

 libavcodec/avpacket.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 03332ac..51b5c52 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -388,10 +388,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;
         }
 
@@ -402,7 +404,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 + FF_INPUT_BUFFER_PADDING_SIZE);
             pkt->side_data[i].size = size;
             pkt->side_data[i].type = p[4]&127;



More information about the ffmpeg-cvslog mailing list