1 http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-1722
3 --- a/filter/image-png.c
4 +++ b/filter/image-png.c
7 * PNG image routines for the Common UNIX Printing System (CUPS).
9 - * Copyright 2007 by Apple Inc.
10 + * Copyright 2007-2008 by Apple Inc.
11 * Copyright 1993-2007 by Easy Software Products.
13 * These coded instructions, statements, and computer programs are the
14 @@ -170,16 +170,56 @@ _cupsImageReadPNG(
15 * Interlaced images must be loaded all at once...
18 + size_t bufsize; /* Size of buffer */
21 if (color_type == PNG_COLOR_TYPE_GRAY ||
22 color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
23 - in = malloc(img->xsize * img->ysize);
25 + bufsize = img->xsize * img->ysize;
27 + if ((bufsize / img->ysize) != img->xsize)
29 + fprintf(stderr, "DEBUG: PNG image dimensions (%ux%u) too large!\n",
30 + (unsigned)width, (unsigned)height);
36 - in = malloc(img->xsize * img->ysize * 3);
38 + bufsize = img->xsize * img->ysize * 3;
40 + if ((bufsize / (img->ysize * 3)) != img->xsize)
42 + fprintf(stderr, "DEBUG: PNG image dimensions (%ux%u) too large!\n",
43 + (unsigned)width, (unsigned)height);
49 + in = malloc(bufsize);
52 bpp = cupsImageGetDepth(img);
53 out = malloc(img->xsize * bpp);
57 + fputs("DEBUG: Unable to allocate memory for PNG image!\n", stderr);
71 * Read the image, interlacing as needed...