summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2017-07-27 12:12:27 +0100
committerBastien Nocera <hadess@hadess.net>2017-07-27 12:21:17 +0100
commitbb5492e3360eec136525677072ca292ec94f7193 (patch)
tree182cb72332008eeedcbbf1d5e249e49743411cb5
parent60805b62cf06aaa8667ce1c2bd6a184b40c49450 (diff)
downloadgdk-pixbuf-bb5492e3360eec136525677072ca292ec94f7193.tar.gz
gdk-pixbuf: Tighten rowstride overflow check
The rowstride is stored as an int, and is an int in the public API. Making it an unsigned int for those calculations would increase the limit, which would obviously cause problems when the calculated value ends up between G_MAXUINT and G_MAXINT in the positives. https://bugzilla.gnome.org/show_bug.cgi?id=765094
-rw-r--r--gdk-pixbuf/gdk-pixbuf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf.c b/gdk-pixbuf/gdk-pixbuf.c
index fb146ba8d..2ee0b2a43 100644
--- a/gdk-pixbuf/gdk-pixbuf.c
+++ b/gdk-pixbuf/gdk-pixbuf.c
@@ -445,7 +445,7 @@ gdk_pixbuf_new (GdkColorspace colorspace,
{
guchar *buf;
unsigned int channels;
- unsigned int rowstride;
+ int rowstride;
g_return_val_if_fail (colorspace == GDK_COLORSPACE_RGB, NULL);
g_return_val_if_fail (bits_per_sample == 8, NULL);
@@ -455,7 +455,7 @@ gdk_pixbuf_new (GdkColorspace colorspace,
channels = has_alpha ? 4 : 3;
/* Overflow? */
- if (width > (G_MAXUINT - 3) / channels)
+ if (width > (G_MAXINT - 3) / channels)
return NULL;
/* Always align rows to 32-bit boundaries */