Commit 81d4b3af authored by Michael Niedermayer's avatar Michael Niedermayer

qpeg: fix overreads.

qpeg should probably be changed to use the checked bytestream reader.
But for now this fixes it and is significantly less work.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 4299dfa5
...@@ -143,7 +143,7 @@ static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size, ...@@ -143,7 +143,7 @@ static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size,
if(delta) { if(delta) {
/* motion compensation */ /* motion compensation */
while((code & 0xF0) == 0xF0) { while(size > 0 && (code & 0xF0) == 0xF0) {
if(delta == 1) { if(delta == 1) {
int me_idx; int me_idx;
int me_w, me_h, me_x, me_y; int me_w, me_h, me_x, me_y;
...@@ -210,6 +210,9 @@ static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size, ...@@ -210,6 +210,9 @@ static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size,
} else if(code >= 0xC0) { /* copy code: 0xC0..0xDF */ } else if(code >= 0xC0) { /* copy code: 0xC0..0xDF */
code &= 0x1F; code &= 0x1F;
if(code + 1 > size)
break;
for(i = 0; i <= code; i++) { for(i = 0; i <= code; i++) {
dst[filled++] = *src++; dst[filled++] = *src++;
if(filled >= width) { if(filled >= width) {
...@@ -227,11 +230,11 @@ static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size, ...@@ -227,11 +230,11 @@ static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size,
code &= 0x3F; code &= 0x3F;
/* codes 0x80 and 0x81 are actually escape codes, /* codes 0x80 and 0x81 are actually escape codes,
skip value minus constant is in the next byte */ skip value minus constant is in the next byte */
if(!code) if(!code) {
skip = (*src++) + 64; skip = (*src++) + 64; size--;
else if(code == 1) } else if(code == 1) {
skip = (*src++) + 320; skip = (*src++) + 320; size--;
else } else
skip = code; skip = code;
filled += skip; filled += skip;
while( filled >= width) { while( filled >= width) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment