|
|
fe0657 |
commit ffec86ed5010c5a2be14f47b33bcf4ed3169a199
|
|
|
fe0657 |
Author: Matthias Clasen <mclasen@redhat.com>
|
|
|
fe0657 |
Date: Mon Jul 13 00:33:40 2015 -0400
|
|
|
fe0657 |
|
|
|
fe0657 |
pixops: Be more careful about integer overflow
|
|
|
fe0657 |
|
|
|
fe0657 |
Our loader code is supposed to handle out-of-memory and overflow
|
|
|
fe0657 |
situations gracefully, reporting errors instead of aborting. But
|
|
|
fe0657 |
if you load an image at a specific size, we also execute our
|
|
|
fe0657 |
scaling code, which was not careful enough about overflow in some
|
|
|
fe0657 |
places.
|
|
|
fe0657 |
|
|
|
fe0657 |
This commit makes the scaling code silently return if it fails to
|
|
|
fe0657 |
allocate filter tables. This is the best we can do, since
|
|
|
fe0657 |
gdk_pixbuf_scale() is not taking a GError.
|
|
|
fe0657 |
|
|
|
fe0657 |
https://bugzilla.gnome.org/show_bug.cgi?id=752297
|
|
|
fe0657 |
|
|
|
fe0657 |
commit 8dba67cb4f38d62a47757741ad41e3f245b4a32a
|
|
|
fe0657 |
Author: Benjamin Otte <otte@redhat.com>
|
|
|
fe0657 |
Date: Mon Aug 17 18:52:47 2015 +0200
|
|
|
fe0657 |
|
|
|
fe0657 |
pixops: Fix oversight for CVE-2015-4491
|
|
|
fe0657 |
|
|
|
fe0657 |
The n_x variable could be made large enough to overflow, too.
|
|
|
fe0657 |
|
|
|
fe0657 |
Also included are various testcases for this vulnerability:
|
|
|
fe0657 |
- The original exploit (adapted for the testsuite)
|
|
|
fe0657 |
- Causing overflow by making both X and Y variables large
|
|
|
fe0657 |
- Causing overflow using only the X variable
|
|
|
fe0657 |
- Causing overflow using only the Y variable
|
|
|
fe0657 |
|
|
|
fe0657 |
https://bugzilla.gnome.org/show_bug.cgi?id=752297
|
|
|
fe0657 |
|
|
|
fe0657 |
diff --git a/gdk-pixbuf/pixops/pixops.c b/gdk-pixbuf/pixops/pixops.c
|
|
|
fe0657 |
index 29a1c14..7f2cbff 100644
|
|
|
fe0657 |
--- a/gdk-pixbuf/pixops/pixops.c
|
|
|
fe0657 |
+++ b/gdk-pixbuf/pixops/pixops.c
|
|
|
fe0657 |
@@ -1272,7 +1272,20 @@ make_filter_table (PixopsFilter *filter)
|
|
|
fe0657 |
int i_offset, j_offset;
|
|
|
fe0657 |
int n_x = filter->x.n;
|
|
|
fe0657 |
int n_y = filter->y.n;
|
|
|
fe0657 |
- int *weights = g_new (int, SUBSAMPLE * SUBSAMPLE * n_x * n_y);
|
|
|
fe0657 |
+ gsize n_weights;
|
|
|
fe0657 |
+ int *weights;
|
|
|
fe0657 |
+
|
|
|
fe0657 |
+ n_weights = SUBSAMPLE * SUBSAMPLE * n_x;
|
|
|
fe0657 |
+ if (n_weights / (SUBSAMPLE * SUBSAMPLE) != n_x)
|
|
|
fe0657 |
+ return NULL; /* overflow, bail */
|
|
|
fe0657 |
+
|
|
|
fe0657 |
+ n_weights *= n_y;
|
|
|
fe0657 |
+ if (n_weights / (SUBSAMPLE * SUBSAMPLE * n_x) != n_y)
|
|
|
fe0657 |
+ return NULL; /* overflow, bail */
|
|
|
fe0657 |
+
|
|
|
fe0657 |
+ weights = g_try_new (int, n_weights);
|
|
|
fe0657 |
+ if (!weights)
|
|
|
fe0657 |
+ return NULL; /* overflow, bail */
|
|
|
fe0657 |
|
|
|
fe0657 |
for (i_offset=0; i_offset < SUBSAMPLE; i_offset++)
|
|
|
fe0657 |
for (j_offset=0; j_offset < SUBSAMPLE; j_offset++)
|
|
|
fe0657 |
@@ -1347,8 +1360,11 @@ pixops_process (guchar *dest_buf,
|
|
|
fe0657 |
if (x_step == 0 || y_step == 0)
|
|
|
fe0657 |
return; /* overflow, bail out */
|
|
|
fe0657 |
|
|
|
fe0657 |
- line_bufs = g_new (guchar *, filter->y.n);
|
|
|
fe0657 |
filter_weights = make_filter_table (filter);
|
|
|
fe0657 |
+ if (!filter_weights)
|
|
|
fe0657 |
+ return; /* overflow, bail out */
|
|
|
fe0657 |
+
|
|
|
fe0657 |
+ line_bufs = g_new (guchar *, filter->y.n);
|
|
|
fe0657 |
|
|
|
fe0657 |
check_shift = check_size ? get_check_shift (check_size) : 0;
|
|
|
fe0657 |
|
|
|
fe0657 |
@@ -1468,7 +1484,7 @@ tile_make_weights (PixopsFilterDimension *dim,
|
|
|
fe0657 |
double scale)
|
|
|
fe0657 |
{
|
|
|
fe0657 |
int n = ceil (1 / scale + 1);
|
|
|
fe0657 |
- double *pixel_weights = g_new (double, SUBSAMPLE * n);
|
|
|
fe0657 |
+ double *pixel_weights = g_malloc_n (sizeof (double) * SUBSAMPLE, n);
|
|
|
fe0657 |
int offset;
|
|
|
fe0657 |
int i;
|
|
|
fe0657 |
|
|
|
fe0657 |
@@ -1526,7 +1542,7 @@ bilinear_magnify_make_weights (PixopsFilterDimension *dim,
|
|
|
fe0657 |
}
|
|
|
fe0657 |
|
|
|
fe0657 |
dim->n = n;
|
|
|
fe0657 |
- dim->weights = g_new (double, SUBSAMPLE * n);
|
|
|
fe0657 |
+ dim->weights = g_malloc_n (sizeof (double) * SUBSAMPLE, n);
|
|
|
fe0657 |
|
|
|
fe0657 |
pixel_weights = dim->weights;
|
|
|
fe0657 |
|
|
|
fe0657 |
@@ -1617,7 +1633,7 @@ bilinear_box_make_weights (PixopsFilterDimension *dim,
|
|
|
fe0657 |
double scale)
|
|
|
fe0657 |
{
|
|
|
fe0657 |
int n = ceil (1/scale + 3.0);
|
|
|
fe0657 |
- double *pixel_weights = g_new (double, SUBSAMPLE * n);
|
|
|
fe0657 |
+ double *pixel_weights = g_malloc_n (sizeof (double) * SUBSAMPLE, n);
|
|
|
fe0657 |
double w;
|
|
|
fe0657 |
int offset, i;
|
|
|
fe0657 |
|