summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2019-03-01 12:18:33 +0100
committerBastien Nocera <hadess@hadess.net>2019-03-01 12:18:33 +0100
commit69f60af1f74be4c71db5b11817134e7951ba8827 (patch)
tree097869b9d42c9a56eb5b881fbe0a5896c8ee53ad
parentf7ef901d25722c42d85f486b88d2644a193a6609 (diff)
downloadgdk-pixbuf-69f60af1f74be4c71db5b11817134e7951ba8827.tar.gz
xpm: Fail when XPM file doesn't contain enough data
Fail hard when the XPM file's advertised width or height does not match the data contained within the file.
-rw-r--r--gdk-pixbuf/io-xpm.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gdk-pixbuf/io-xpm.c b/gdk-pixbuf/io-xpm.c
index 8a4ceee71..7fc588715 100644
--- a/gdk-pixbuf/io-xpm.c
+++ b/gdk-pixbuf/io-xpm.c
@@ -602,8 +602,14 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl
pixtmp = gdk_pixbuf_get_pixels (pixbuf) + ycnt * rowstride;
buffer = (*get_buf) (op_body, handle);
- if ((!buffer) || (strlen (buffer) < wbytes))
- continue;
+ if ((!buffer) || (strlen (buffer) < wbytes)) {
+ /* Advertised width doesn't match pixels */
+ g_set_error_literal (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ _("Dimensions do not match data"));
+ goto out;
+ }
for (n = 0, xcnt = 0; n < wbytes; n += cpp, xcnt++) {
strncpy (pixel_str, &buffer[n], cpp);