[FFmpeg-devel] [PATCH 07/13] sgidec: safer check for buffer overflow

Paul B Mahol onemda at gmail.com
Sat Jul 27 00:26:49 CEST 2013


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavcodec/sgidec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c
index 7bb80a5..b8e406f 100644
--- a/libavcodec/sgidec.c
+++ b/libavcodec/sgidec.c
@@ -58,7 +58,7 @@ static int expand_rle_row(SgiState *s, uint8_t *out_buf,
         }
 
         /* Check for buffer overflow. */
-        if (out_buf + pixelstride * (count - 1) >= out_end)
+        if (out_end - out_buf <= pixelstride * (count - 1))
             return AVERROR_INVALIDDATA;
 
         if (pixel & 0x80) {
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list