--- OLD/pnm/giftopnm.c Thu Jan 1 00:00:00 1970 +++ NEW/pnm/giftopnm.c Thu Jan 1 00:00:00 1970 @@ -267,7 +267,7 @@ foreground = buf[10]; background = buf[11]; - while (GetDataBlock(fd, (unsigned char*) buf) != 0) { + while (GetDataBlock(fd, (unsigned char*) buf) > 0) { PPM_ASSIGN(image[ypos][xpos], cmap[CM_RED][v], cmap[CM_GREEN][v], @@ -284,7 +284,7 @@ break; case 0xfe: /* Comment Extension */ str = "Comment Extension"; - while (GetDataBlock(fd, (unsigned char*) buf) != 0) { + while (GetDataBlock(fd, (unsigned char*) buf) > 0) { if (showComment) pm_message("gif comment: %s", buf ); } @@ -298,7 +298,7 @@ if ((buf[0] & 0x1) != 0) Gif89.transparent = buf[3]; - while (GetDataBlock(fd, (unsigned char*) buf) != 0) + while (GetDataBlock(fd, (unsigned char*) buf) > 0) ; return FALSE; default: @@ -309,7 +309,7 @@ pm_message("got a '%s' extension", str ); - while (GetDataBlock(fd, (unsigned char*) buf) != 0) + while (GetDataBlock(fd, (unsigned char*) buf) > 0) ; return FALSE; @@ -348,7 +348,7 @@ static unsigned char buf[280]; static int curbit, lastbit, done, last_byte; int i, j, ret; - unsigned char count; + int count; if (flag) { curbit = 0; @@ -368,6 +368,7 @@ if ((count = GetDataBlock(fd, &buf[2])) == 0) done = TRUE; + if (count < 0) return(-1); last_byte = 2 + count; curbit = (curbit - lastbit) + 16;