[gdk-pixbuf/wip/hadess/better-xpm-checks: 4/5] xpm: Fail when XPM file doesn't contain enough data



commit 69f60af1f74be4c71db5b11817134e7951ba8827
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Mar 1 12:18:33 2019 +0100

    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.

 gdk-pixbuf/io-xpm.c | 10 ++++++++--
 1 file 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]