diff --git a/ChangeLog b/ChangeLog index 0cd47a73..69b247b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,7 +23,7 @@ Changes since version 0.80.1: - Added kinput2 bug workaround in stock WMWindowAttributes (Seiichi SATO ) - Added Belarusian translation (Ihar Viarheichyk ) -- Fixed wrlib to not try to load braindead images with 0x0 size +- Fixed wrlib not to load braindead images with 0 sized width or height - Removed double no-position-display when cycling position display types with Shift key while moving windows. - Changed the default position display while moving a window to 'Center'. diff --git a/wrlib/gif.c b/wrlib/gif.c index 0b5ad654..b12fce16 100644 --- a/wrlib/gif.c +++ b/wrlib/gif.c @@ -62,7 +62,7 @@ RLoadGIF(RContext *context, char *file, int index) RErrorCode = RERR_BADINDEX; gif = DGifOpenFileName(file); - + if (!gif) { switch (GifLastError()) { case D_GIF_ERR_OPEN_FAILED: @@ -78,6 +78,12 @@ RLoadGIF(RContext *context, char *file, int index) return NULL; } + if (gif->Image.Width<1 || gif->Image.Height<1) { + DGifCloseFile(gif); + RErrorCode = RERR_BADIMAGEFILE; + return NULL; + } + colormap = gif->SColorMap; i = 0; @@ -206,7 +212,7 @@ giferr: default: RErrorCode = RERR_BADIMAGEFILE; break; - } + } bye: if (image) RReleaseImage(image); diff --git a/wrlib/nxpm.c b/wrlib/nxpm.c index aa1dcb63..1003a100 100644 --- a/wrlib/nxpm.c +++ b/wrlib/nxpm.c @@ -86,9 +86,9 @@ RGetImageFromXPMData(RContext *context, char **data) int w, h, ccount, csize; if (sscanf(data[line++], "%i %i %i %i", &w, &h, &ccount, &csize)!=4 - || w <= 1 || h <= 1 || ccount <= 0 || csize <= 0) + || w <= 0 || h <= 0 || ccount <= 0 || csize <= 0) goto bad_format; - + if (csize!=1 && csize!=2) goto bad_format; diff --git a/wrlib/tiff.c b/wrlib/tiff.c index d5dff932..4d611d9f 100644 --- a/wrlib/tiff.c +++ b/wrlib/tiff.c @@ -81,10 +81,10 @@ RLoadTIFF(RContext *context, char *file, int index) TIFFClose(tif); return NULL; } - + /* read data */ ptr = data = (uint32*)_TIFFmalloc(width * height * sizeof(uint32)); - + if (!data) { RErrorCode = RERR_NOMEMORY; } else {