Skip to content

Commit

Permalink
gif: Don't get into infinite loops on truncated files.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Sep 26, 2018
1 parent 8373c58 commit 06bdebe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions IMG_gif.c
Expand Up @@ -317,7 +317,7 @@ DoExtension(SDL_RWops *src, int label)
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 */
Expand All @@ -329,7 +329,7 @@ DoExtension(SDL_RWops *src, int label)
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:
Expand All @@ -338,7 +338,7 @@ DoExtension(SDL_RWops *src, int label)
break;
}

while (GetDataBlock(src, (unsigned char *) buf) != 0)
while (GetDataBlock(src, (unsigned char *) buf) > 0)
;

return FALSE;
Expand Down Expand Up @@ -387,7 +387,7 @@ GetCode(SDL_RWops *src, int code_size, int flag)
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;
Expand Down

0 comments on commit 06bdebe

Please sign in to comment.