}
w = header[1];
h = header[2];
- alpha = header[3];
- compression = header[4];
- if ((w > 8192) || (h > 8192))
+ if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
{
free(ret);
e_db_close(db);
return 0;
}
+ alpha = header[3];
+ compression = header[4];
+
if ((compression == 0) && (size < ((w * h * 4) + 32)))
{
free(ret);
}
w = header[1];
h = header[2];
- alpha = header[3];
- compression = header[4];
- if ((w > 8192) || (h > 8192))
+ if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
{
free(ret);
e_db_close(db);
return 0;
}
+
+ alpha = header[3];
+ compression = header[4];
+
if ((compression == 0) && (size < ((w * h * 4) + 32)))
{
free(ret);
eet_close(ef);
return 0;
}
- if ((w > 8192) || (h > 8192))
+ if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
{
eet_close(ef);
return 0;
eet_close(ef);
return 0;
}
- if ((w > 8192) || (h > 8192))
+ if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
{
free(body);
eet_close(ef);
}
w = gif->Image.Width;
h = gif->Image.Height;
- done = 1;
+ if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
+ {
+ DGifCloseFile(gif);
+ return 0;
+ }
+ done = 1;
}
else if (rec == EXTENSION_RECORD_TYPE)
{
int ext_code;
GifByteType *ext;
-
+
ext = NULL;
DGifGetExtension(gif, &ext_code, &ext);
while (ext)
}
w = cinfo.output_width;
h = cinfo.output_height;
+ if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
+ {
+ jpeg_destroy_decompress(&cinfo);
+ return 0;
+ }
if (im->load_opts.scale_down_by > 1)
{
w /= im->load_opts.scale_down_by;
png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *) (&w32),
(png_uint_32 *) (&h32), &bit_depth, &color_type,
&interlace_type, NULL, NULL);
+ if ((w32 < 1) || (h32 < 1) || (w32 > 8192) || (h32 > 8192))
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
+ fclose(f);
+ return 0;
+ }
if (!im->image)
im->image = evas_common_image_surface_new(im);
if (!im->image)
png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *) (&w32),
(png_uint_32 *) (&h32), &bit_depth, &color_type,
&interlace_type, NULL, NULL);
- im->image->w = (int) w32;
- im->image->h = (int) h32;
+ if ((w32 != im->image->w) || (h32 != im->image->h))
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
+ fclose(f);
+ return 0;
+ }
if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_expand(png_ptr);
if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) hasa = 1;
if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
rsvg_handle_get_dimensions(rsvg, &dim);
w = dim.width;
h = dim.height;
+ if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
+ {
+ rsvg_handle_free(rsvg);
+ chdir(pcwd);
+ return 0;
+ }
if (im->load_opts.scale_down_by > 1)
{
w /= im->load_opts.scale_down_by;
rsvg_handle_get_dimensions(rsvg, &dim);
w = dim.width;
h = dim.height;
+ if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
+ {
+ rsvg_handle_free(rsvg);
+ chdir(pcwd);
+ return 0;
+ }
if (im->load_opts.scale_down_by > 1)
{
w /= im->load_opts.scale_down_by;
raster(TIFFRGBAImage_Extra * img, uint32 * rast,
uint32 x, uint32 y, uint32 w, uint32 h)
{
- uint32 image_width, image_height;
+ int image_width, image_height;
uint32 *pixel, pixel_value;
int i, j, dy, rast_offset;
DATA32 *buffer_pixel, *buffer = img->image->image->data;
- int alpha_premult = (EXTRASAMPLE_UNASSALPHA==img->rgba.alpha);
+ int alpha_premult;
image_width = img->image->image->w;
image_height = img->image->image->h;
/* I don't understand why, but that seems to be what's going on. */
/* libtiff needs better docs! */
+ if (img->rgba.alpha == EXTRASAMPLE_UNASSALPHA)
+ alpha_premult = 1;
for (i = y, rast_offset = 0; i > dy; i--, rast_offset--)
{
pixel = rast + (rast_offset * image_width);
}
if (tiff_image.alpha != EXTRASAMPLE_UNSPECIFIED)
im->flags |= RGBA_IMAGE_HAS_ALPHA;
+ if ((tiff_image.width < 1) || (tiff_image.height < 1) ||
+ (tiff_image.width > 8192) || (tiff_image.height > 8192))
+ {
+ TIFFClose(tif);
+ return 0;
+ }
im->image->w = tiff_image.width;
im->image->h = tiff_image.height;
}
if (rgba_image.rgba.alpha != EXTRASAMPLE_UNSPECIFIED)
im->flags |= RGBA_IMAGE_HAS_ALPHA;
+ if ((rgba_image.rgba.width != im->image->w) ||
+ (rgba_image.rgba.height != im->image->h))
+ {
+ TIFFClose(tif);
+ return 0;
+ }
im->image->w = rgba_image.rgba.width;
im->image->h = rgba_image.rgba.height;
rgba_image.num_pixels = num_pixels = im->image->w * im->image->h;
xpm_parse_done();
return 0;
}
- if ((w > 32767) || (w < 1))
+ if ((w > 8192) || (w < 1))
{
fprintf(stderr,
- "XPM ERROR: Image width > 32767 or < 1 pixels for file\n");
+ "XPM ERROR: Image width > 8192 or < 1 pixels for file\n");
free(line);
fclose(f);
xpm_parse_done();
return 0;
}
- if ((h > 32767) || (h < 1))
+ if ((h > 8192) || (h < 1))
{
fprintf(stderr,
- "XPM ERROR: Image height > 32767 or < 1 pixels for file\n");
+ "XPM ERROR: Image height > 8192 or < 1 pixels for file\n");
free(line);
fclose(f);
xpm_parse_done();
if (has_alpha)
{
+ uint16 extras[] = { EXTRASAMPLE_ASSOCALPHA };
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 4);
- TIFFSetField(tif, TIFFTAG_EXTRASAMPLES, EXTRASAMPLE_ASSOCALPHA);
+ TIFFSetField(tif, TIFFTAG_EXTRASAMPLES, 1, extras);
}
else
{