summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanno Boeck <hanno@hboeck.de>2016-07-06 13:05:00 +0000
committerMatthias Clasen <mclasen@redhat.com>2016-08-02 13:22:00 -0400
commit0cff83e985fba5350695c00ed1ac30fc31ec5960 (patch)
tree05e5b41d849a17281a56a08a8d6f224a8a452c56
parentb69009f2a2de151103ed87e9594615ba0fe72daf (diff)
downloadgdk-pixbuf-0cff83e985fba5350695c00ed1ac30fc31ec5960.tar.gz
ico: Always set errors
When the ico header turn out to be bad, always set an error when we fail. Otherwise, applications will get confused. This commit also adds an example image with a bad ico header. https://bugzilla.gnome.org/show_bug.cgi?id=768484
-rw-r--r--gdk-pixbuf/io-ico.c14
-rw-r--r--tests/test-images/randomly-modified/bad-header.icobin0 -> 6 bytes
2 files changed, 12 insertions, 2 deletions
diff --git a/gdk-pixbuf/io-ico.c b/gdk-pixbuf/io-ico.c
index 86714affe..82d3e4e7a 100644
--- a/gdk-pixbuf/io-ico.c
+++ b/gdk-pixbuf/io-ico.c
@@ -258,8 +258,13 @@ static void DecodeHeader(guchar *Data, gint Bytes,
State->HeaderBuf = tmp;
State->BytesInHeaderBuf = State->HeaderSize;
}
- if (Bytes < State->HeaderSize)
+ if (Bytes < State->HeaderSize) {
+ g_set_error_literal (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ _("Not enough bytes for header"));
return;
+ }
/* Now iterate through the ICONDIRENTRY structures, and sort them by
* which one we think is "best" (essentially the largest) */
@@ -399,8 +404,13 @@ static void DecodeHeader(guchar *Data, gint Bytes,
State->HeaderBuf = tmp;
State->BytesInHeaderBuf = State->HeaderSize;
}
- if (Bytes < State->HeaderSize)
+ if (Bytes < State->HeaderSize) {
+ g_set_error_literal (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ _("Not enough bytes for header"));
return;
+ }
/* Negative heights mean top-down pixel-order */
if (State->Header.height < 0) {
diff --git a/tests/test-images/randomly-modified/bad-header.ico b/tests/test-images/randomly-modified/bad-header.ico
new file mode 100644
index 000000000..ddf451575
--- /dev/null
+++ b/tests/test-images/randomly-modified/bad-header.ico
Binary files differ