[Commits] SDL_image: gif: Don't get into infinite loops on truncated files.

libsdl.org revision control commits-owner at libsdl.org
Wed Sep 26 12:19:38 PDT 2018


details:   https://hg.libsdl.org/SDL_image/rev/19beb4a1bb54
changeset: 586:19beb4a1bb54
user:      Ryan C. Gordon <icculus at icculus.org>
date:      Wed Sep 26 15:19:17 2018 -0400
description:
gif: Don't get into infinite loops on truncated files.

diffstat:

 IMG_gif.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r 170d7d32e4a8 -r 19beb4a1bb54 IMG_gif.c
--- a/IMG_gif.c	Wed Sep 26 14:58:31 2018 -0400
+++ b/IMG_gif.c	Wed Sep 26 15:19:17 2018 -0400
@@ -317,7 +317,7 @@
     break;
     case 0xfe:          /* Comment Extension */
     str = "Comment Extension";
-    while (GetDataBlock(src, (unsigned char *) buf) != 0)
+    while (GetDataBlock(src, (unsigned char *) buf) > 0)
         ;
     return FALSE;
     case 0xf9:          /* Graphic Control Extension */
@@ -329,7 +329,7 @@
     if ((buf[0] & 0x1) != 0)
         Gif89.transparent = buf[3];
 
-    while (GetDataBlock(src, (unsigned char *) buf) != 0)
+    while (GetDataBlock(src, (unsigned char *) buf) > 0)
         ;
     return FALSE;
     default:
@@ -338,7 +338,7 @@
     break;
     }
 
-    while (GetDataBlock(src, (unsigned char *) buf) != 0)
+    while (GetDataBlock(src, (unsigned char *) buf) > 0)
     ;
 
     return FALSE;
@@ -387,7 +387,7 @@
     buf[0] = buf[last_byte - 2];
     buf[1] = buf[last_byte - 1];
 
-    if ((count = GetDataBlock(src, &buf[2])) == 0)
+    if ((count = GetDataBlock(src, &buf[2])) <= 0)
         done = TRUE;
 
     last_byte = 2 + count;


More information about the commits mailing list