forked from old/legacy-imlib2
Relax 8192 pixel dimension limit (ticket 361).
SVN revision: 41412
This commit is contained in:
parent
ebab7f27bb
commit
dedebfcc1a
|
@ -34,6 +34,9 @@
|
||||||
# define DATA8 unsigned char
|
# define DATA8 unsigned char
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
/* Maximum image dimension */
|
||||||
|
#define IMLIB_MAX_DIM (2 << 20)
|
||||||
|
|
||||||
/* opaque data types */
|
/* opaque data types */
|
||||||
typedef void *Imlib_Context;
|
typedef void *Imlib_Context;
|
||||||
typedef void *Imlib_Image;
|
typedef void *Imlib_Image;
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
#include "rend.h"
|
#include "rend.h"
|
||||||
#include "rotate.h"
|
#include "rotate.h"
|
||||||
|
|
||||||
|
/* Maximum pixmap dimension (65535) */
|
||||||
|
#define X_MAX_DIM ((2 << 16) - 1)
|
||||||
|
|
||||||
/* size of the lines per segment we scale / render at a time */
|
/* size of the lines per segment we scale / render at a time */
|
||||||
#define LINESIZE 16
|
#define LINESIZE 16
|
||||||
|
|
||||||
|
@ -279,7 +282,7 @@ __imlib_RenderImage(Display * d, ImlibImage * im,
|
||||||
if ((sw <= 0) || (sh <= 0))
|
if ((sw <= 0) || (sh <= 0))
|
||||||
return;
|
return;
|
||||||
/* if the output is too big (8k arbitary limit here) dont bother */
|
/* if the output is too big (8k arbitary limit here) dont bother */
|
||||||
if ((abs(dw) > 8192) || (abs(dh) > 8192))
|
if ((abs(dw) > X_MAX_DIM) || (abs(dh) > X_MAX_DIM))
|
||||||
return;
|
return;
|
||||||
/* clip the source rect to be within the actual image */
|
/* clip the source rect to be within the actual image */
|
||||||
psx = sx;
|
psx = sx;
|
||||||
|
@ -304,7 +307,7 @@ __imlib_RenderImage(Display * d, ImlibImage * im,
|
||||||
if ((sw <= 0) || (sh <= 0))
|
if ((sw <= 0) || (sh <= 0))
|
||||||
return;
|
return;
|
||||||
/* if the output is too big (8k arbitary limit here) dont bother */
|
/* if the output is too big (8k arbitary limit here) dont bother */
|
||||||
if ((abs(dw) > 8192) || (abs(dh) > 8192))
|
if ((abs(dw) > X_MAX_DIM) || (abs(dh) > X_MAX_DIM))
|
||||||
return;
|
return;
|
||||||
/* if we are scaling the image at all make a scaling buffer */
|
/* if we are scaling the image at all make a scaling buffer */
|
||||||
if (!((sw == dw) && (sh == dh)))
|
if (!((sw == dw) && (sh == dh)))
|
||||||
|
|
|
@ -36,7 +36,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
|
if ((w < 1) || (h < 1) || (w > IMLIB_MAX_DIM) || (h > IMLIB_MAX_DIM))
|
||||||
{
|
{
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -193,7 +193,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
|
if ((w < 1) || (h < 1) || (w > IMLIB_MAX_DIM) || (h > IMLIB_MAX_DIM))
|
||||||
{
|
{
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -58,7 +58,8 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
}
|
}
|
||||||
w = gif->Image.Width;
|
w = gif->Image.Width;
|
||||||
h = gif->Image.Height;
|
h = gif->Image.Height;
|
||||||
if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
|
if ((w < 1) || (h < 1) ||
|
||||||
|
(w > IMLIB_MAX_DIM) || (h > IMLIB_MAX_DIM))
|
||||||
{
|
{
|
||||||
DGifCloseFile(gif);
|
DGifCloseFile(gif);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -76,7 +76,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
{
|
{
|
||||||
im->w = w = cinfo.output_width;
|
im->w = w = cinfo.output_width;
|
||||||
im->h = h = cinfo.output_height;
|
im->h = h = cinfo.output_height;
|
||||||
if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
|
if ((w < 1) || (h < 1) || (w > IMLIB_MAX_DIM) || (h > IMLIB_MAX_DIM))
|
||||||
{
|
{
|
||||||
im->w = im->h = 0;
|
im->w = im->h = 0;
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
|
@ -96,7 +96,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
im->h = h = cinfo.output_height;
|
im->h = h = cinfo.output_height;
|
||||||
|
|
||||||
if ((cinfo.rec_outbuf_height > 16) || (cinfo.output_components <= 0) ||
|
if ((cinfo.rec_outbuf_height > 16) || (cinfo.output_components <= 0) ||
|
||||||
(w < 1) || (h < 1) || (w > 8192) || (h > 8192))
|
(w < 1) || (h < 1) || (w > IMLIB_MAX_DIM) || (h > IMLIB_MAX_DIM))
|
||||||
{
|
{
|
||||||
im->w = im->h = 0;
|
im->w = im->h = 0;
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
|
|
|
@ -402,7 +402,8 @@ ILBM ilbm;
|
||||||
|
|
||||||
im->w = L2RWORD(ilbm.bmhd.data);
|
im->w = L2RWORD(ilbm.bmhd.data);
|
||||||
im->h = L2RWORD(ilbm.bmhd.data + 2);
|
im->h = L2RWORD(ilbm.bmhd.data + 2);
|
||||||
if ((im->w < 1) || (im->h < 1) || (im->w > 8192) || (im->h > 8192))
|
if ((im->w < 1) || (im->h < 1) ||
|
||||||
|
(im->w > IMLIB_MAX_DIM) || (im->h > IMLIB_MAX_DIM))
|
||||||
{
|
{
|
||||||
ok = 0;
|
ok = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
&interlace_type, NULL, NULL);
|
&interlace_type, NULL, NULL);
|
||||||
im->w = (int)w32;
|
im->w = (int)w32;
|
||||||
im->h = (int)h32;
|
im->h = (int)h32;
|
||||||
if ((w32 < 1) || (h32 < 1) || (w32 > 8192) || (h32 > 8192))
|
if ((w32 < 1) || (h32 < 1) || (w32 > IMLIB_MAX_DIM) || (h32 > IMLIB_MAX_DIM))
|
||||||
{
|
{
|
||||||
png_read_end(png_ptr, info_ptr);
|
png_read_end(png_ptr, info_ptr);
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
|
||||||
|
|
|
@ -103,7 +103,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
|
|
||||||
im->w = w;
|
im->w = w;
|
||||||
im->h = h;
|
im->h = h;
|
||||||
if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
|
if ((w < 1) || (h < 1) || (w > IMLIB_MAX_DIM) || (h > IMLIB_MAX_DIM))
|
||||||
{
|
{
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -283,7 +283,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
im->w = (header->widthHi << 8) | header->widthLo;
|
im->w = (header->widthHi << 8) | header->widthLo;
|
||||||
im->h = (header->heightHi << 8) | header->heightLo;
|
im->h = (header->heightHi << 8) | header->heightLo;
|
||||||
|
|
||||||
if ((im->w < 1) || (im->h < 1) || (im->w > 8192) || (im->h > 8192))
|
if ((im->w < 1) || (im->h < 1) ||
|
||||||
|
(im->w > IMLIB_MAX_DIM) || (im->h > IMLIB_MAX_DIM))
|
||||||
{
|
{
|
||||||
munmap(seg, ss.st_size);
|
munmap(seg, ss.st_size);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
|
@ -184,7 +184,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
rgba_image.image = im;
|
rgba_image.image = im;
|
||||||
im->w = width = rgba_image.rgba.width;
|
im->w = width = rgba_image.rgba.width;
|
||||||
im->h = height = rgba_image.rgba.height;
|
im->h = height = rgba_image.rgba.height;
|
||||||
if ((width < 1) || (height < 1) || (width > 8192) || (height > 8192))
|
if ((width < 1) || (height < 1) ||
|
||||||
|
(width > IMLIB_MAX_DIM) || (height > IMLIB_MAX_DIM))
|
||||||
{
|
{
|
||||||
TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
|
TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
|
||||||
TIFFClose(tif);
|
TIFFClose(tif);
|
||||||
|
|
|
@ -204,19 +204,21 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
xpm_parse_done();
|
xpm_parse_done();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((w > 8192) || (w < 1))
|
if ((w > IMLIB_MAX_DIM) || (w < 1))
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"IMLIB ERROR: Image width > 8192 or < 1 pixels for file\n");
|
"IMLIB ERROR: Image width > %d or < 1 pixels for file\n",
|
||||||
|
IMLIB_MAX_DIM);
|
||||||
free(line);
|
free(line);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
xpm_parse_done();
|
xpm_parse_done();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((h > 8192) || (h < 1))
|
if ((h > IMLIB_MAX_DIM) || (h < 1))
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"IMLIB ERROR: Image height > 8192 or < 1 pixels for file\n");
|
"IMLIB ERROR: Image height > %d or < 1 pixels for file\n",
|
||||||
|
IMLIB_MAX_DIM);
|
||||||
free(line);
|
free(line);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
xpm_parse_done();
|
xpm_parse_done();
|
||||||
|
|
Loading…
Reference in New Issue