Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.2
gimp
gimp-CVE-2012-5576.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gimp-CVE-2012-5576.patch of Package gimp
From 0b35f6a082a0b3c372c568ea6bde39a4796acde2 Mon Sep 17 00:00:00 2001 From: Michael Natterer <mitch@gimp.org> Date: Wed, 07 Nov 2012 23:16:31 +0000 Subject: Bug 687392 - Memory corruption vulnerability when reading XWD files Applied and enhanced patch from andres which makes file-xwd detect this kind of file corruption and abort loading with an error message. --- Index: gimp-2.6.11/plug-ins/common/file-xwd.c =================================================================== --- gimp-2.6.11.orig/plug-ins/common/file-xwd.c +++ gimp-2.6.11/plug-ins/common/file-xwd.c @@ -186,11 +186,13 @@ static gint32 load_xwd_f2_d16_b16 (const static gint32 load_xwd_f2_d24_b32 (const gchar *, FILE *, L_XWDFILEHEADER *, - L_XWDCOLOR *); + L_XWDCOLOR *, + GError **); static gint32 load_xwd_f1_d24_b1 (const gchar *, FILE *, L_XWDFILEHEADER *, - L_XWDCOLOR *); + L_XWDCOLOR *, + GError **); static L_CARD32 read_card32 (FILE *, gint *); @@ -536,7 +538,8 @@ load_image (const gchar *filename, case 1: /* Single plane pixmap */ if ((depth <= 24) && (bpp == 1)) { - image_ID = load_xwd_f1_d24_b1 (filename, ifp, &xwdhdr, xwdcolmap); + image_ID = load_xwd_f1_d24_b1 (filename, ifp, &xwdhdr, xwdcolmap, + error); } break; @@ -555,7 +558,8 @@ load_image (const gchar *filename, } else if ((depth <= 24) && ((bpp == 24) || (bpp == 32))) { - image_ID = load_xwd_f2_d24_b32 (filename, ifp, &xwdhdr, xwdcolmap); + image_ID = load_xwd_f2_d24_b32 (filename, ifp, &xwdhdr, xwdcolmap, + error); } break; } @@ -565,7 +569,7 @@ load_image (const gchar *filename, if (xwdcolmap) g_free (xwdcolmap); - if (image_ID == -1) + if (image_ID == -1 && ! (error && *error)) g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("XWD-file %s has format %d, depth %d and bits per pixel %d. " "Currently this is not supported."), @@ -1615,10 +1619,11 @@ load_xwd_f2_d16_b16 (const gchar *fi /* Load XWD with pixmap_format 2, pixmap_depth up to 24, bits_per_pixel 24/32 */ static gint32 -load_xwd_f2_d24_b32 (const gchar *filename, - FILE *ifp, - L_XWDFILEHEADER *xwdhdr, - L_XWDCOLOR *xwdcolmap) +load_xwd_f2_d24_b32 (const gchar *filename, + FILE *ifp, + L_XWDFILEHEADER *xwdhdr, + L_XWDCOLOR *xwdcolmap, + GError **error) { register guchar *dest, lsbyte_first; gint width, height, linepad, i, j, c0, c1, c2, c3; @@ -1643,12 +1648,6 @@ load_xwd_f2_d24_b32 (const gchar *fi width = xwdhdr->l_pixmap_width; height = xwdhdr->l_pixmap_height; - image_ID = create_new_image (filename, width, height, GIMP_RGB, - &layer_ID, &drawable, &pixel_rgn); - - tile_height = gimp_tile_height (); - data = g_malloc (tile_height * width * 3); - redmask = xwdhdr->l_red_mask; greenmask = xwdhdr->l_green_mask; bluemask = xwdhdr->l_blue_mask; @@ -1676,6 +1675,22 @@ load_xwd_f2_d24_b32 (const gchar *fi maxblue = 0; while (bluemask >> (blueshift + maxblue)) maxblue++; maxblue = (1 << maxblue) - 1; + if (maxred > sizeof (redmap) || + maxgreen > sizeof (greenmap) || + maxblue > sizeof (bluemap)) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("XWD-file %s is corrupt."), + gimp_filename_to_utf8 (filename)); + return -1; + } + + image_ID = create_new_image (filename, width, height, GIMP_RGB, + &layer_ID, &drawable, &pixel_rgn); + + tile_height = gimp_tile_height (); + data = g_malloc (tile_height * width * 3); + /* Set map-arrays for red, green, blue */ for (red = 0; red <= maxred; red++) redmap[red] = (red * 255) / maxred; @@ -1815,10 +1830,11 @@ load_xwd_f2_d24_b32 (const gchar *fi /* Load XWD with pixmap_format 1, pixmap_depth up to 24, bits_per_pixel 1 */ static gint32 -load_xwd_f1_d24_b1 (const gchar *filename, - FILE *ifp, - L_XWDFILEHEADER *xwdhdr, - L_XWDCOLOR *xwdcolmap) +load_xwd_f1_d24_b1 (const gchar *filename, + FILE *ifp, + L_XWDFILEHEADER *xwdhdr, + L_XWDCOLOR *xwdcolmap, + GError **error) { register guchar *dest, outmask, inmask, do_reverse; gint width, height, linepad, i, j, plane, fromright; @@ -1853,13 +1869,6 @@ load_xwd_f1_d24_b1 (const gchar *fil indexed = (xwdhdr->l_pixmap_depth <= 8); bytes_per_pixel = (indexed ? 1 : 3); - image_ID = create_new_image (filename, width, height, - indexed ? GIMP_INDEXED : GIMP_RGB, - &layer_ID, &drawable, &pixel_rgn); - - tile_height = gimp_tile_height (); - data = g_malloc (tile_height * width * bytes_per_pixel); - linepad = xwdhdr->l_bytes_per_line - (xwdhdr->l_pixmap_width+7)/8; if (linepad < 0) @@ -1908,6 +1917,16 @@ load_xwd_f1_d24_b1 (const gchar *fil maxblue = 0; while (bluemask >> (blueshift + maxblue)) maxblue++; maxblue = (1 << maxblue) - 1; + if (maxred > sizeof (redmap) || + maxgreen > sizeof (greenmap) || + maxblue > sizeof (bluemap)) + { + g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, + _("XWD-file %s is corrupt."), + gimp_filename_to_utf8 (filename)); + return -1; + } + /* Set map-arrays for red, green, blue */ for (red = 0; red <= maxred; red++) redmap[red] = (red * 255) / maxred; @@ -1917,6 +1936,13 @@ load_xwd_f1_d24_b1 (const gchar *fil bluemap[blue] = (blue * 255) / maxblue; } + image_ID = create_new_image (filename, width, height, + indexed ? GIMP_INDEXED : GIMP_RGB, + &layer_ID, &drawable, &pixel_rgn); + + tile_height = gimp_tile_height (); + data = g_malloc (tile_height * width * bytes_per_pixel); + ncols = xwdhdr->l_colormap_entries; if (xwdhdr->l_ncolors < ncols) ncols = xwdhdr->l_ncolors;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor