Browse code

avcodec/sgidec: fix count check

Fixes: asan_heap-oob_22b30d4_39_038.sgi
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2014/10/28 04:48:58
Showing 1 changed files
... ...
@@ -98,7 +98,7 @@ static int expand_rle_row16(SgiState *s, uint16_t *out_buf,
98 98
             break;
99 99
 
100 100
         /* Check for buffer overflow. */
101
-        if (pixelstride * (count - 1) >= len) {
101
+        if (out_end - out_buf <= pixelstride * (count - 1)) {
102 102
             av_log(s->avctx, AV_LOG_ERROR, "Invalid pixel count.\n");
103 103
             return AVERROR_INVALIDDATA;
104 104
         }