From 06bdebe39003f18e3dc157c64d47b9f7e719a4df Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 26 Sep 2018 15:19:17 -0400 Subject: [PATCH] gif: Don't get into infinite loops on truncated files. --- IMG_gif.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IMG_gif.c b/IMG_gif.c index 0fd88f28..32618a0b 100644 --- a/IMG_gif.c +++ b/IMG_gif.c @@ -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 */ @@ -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: @@ -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; @@ -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;