[gimp] file-gif-load: Fail early in several other places if GetDataBlocks() fails (Bug #737375)
- From: Mukund Sivaraman <muks src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] file-gif-load: Fail early in several other places if GetDataBlocks() fails (Bug #737375)
- Date: Thu, 25 Sep 2014 18:22:15 +0000 (UTC)
commit 2377c8c2a9afc88d1a5665b0b30210459d17dcd8
Author: Mukund Sivaraman <muks banu com>
Date: Thu Sep 25 23:49:11 2014 +0530
file-gif-load: Fail early in several other places if GetDataBlocks() fails (Bug #737375)
plug-ins/common/file-gif-load.c | 38 +++++++++++++++++++++++++++++++++++---
1 files changed, 35 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/common/file-gif-load.c b/plug-ins/common/file-gif-load.c
index b07a20a..a45a6d9 100644
--- a/plug-ins/common/file-gif-load.c
+++ b/plug-ins/common/file-gif-load.c
@@ -492,6 +492,11 @@ load_image (const gchar *filename,
GifScreen.Height);
}
+ if (image_ID < 0)
+ {
+ break;
+ }
+
if (comment_parasite != NULL)
{
if (! thumbnail)
@@ -656,7 +661,7 @@ GetDataBlock (FILE *fd,
return -1;
}
- ZeroDataBlock = count == 0;
+ ZeroDataBlock = (count == 0);
if ((count != 0) && (! ReadOK (fd, buf, count)))
{
@@ -698,8 +703,15 @@ GetCode (FILE *fd,
buf[0] = buf[last_byte - 2];
buf[1] = buf[last_byte - 1];
- if ((count = GetDataBlock (fd, &buf[2])) <= 0)
- done = TRUE;
+ count = GetDataBlock (fd, &buf[2]);
+ if (count < 0)
+ {
+ return -1;
+ }
+ else if (count == 0)
+ {
+ done = TRUE;
+ }
last_byte = 2 + count;
curbit = (curbit - lastbit) + 16;
@@ -777,6 +789,11 @@ LZWReadByte (FILE *fd,
}
while (firstcode == clear_code);
+ if (firstcode < 0)
+ {
+ return -1;
+ }
+
return firstcode & 255;
}
@@ -804,6 +821,11 @@ LZWReadByte (FILE *fd,
sp = stack;
firstcode = oldcode = GetCode (fd, code_size, FALSE);
+ if (firstcode < 0)
+ {
+ return -1;
+ }
+
return firstcode & 255;
}
else if (code == end_code || code > max_code)
@@ -865,6 +887,11 @@ LZWReadByte (FILE *fd,
return (*--sp) & 255;
}
+ if (code < 0)
+ {
+ return -1;
+ }
+
return code & 255;
}
@@ -1172,6 +1199,11 @@ ReadImage (FILE *fd,
break;
}
+ if (v < 0)
+ {
+ return -1;
+ }
+
fini:
if (LZWReadByte (fd, FALSE, c) >= 0)
g_print ("GIF: too much input data, ignoring extra...\n");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]