Check for invalid image size

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24381 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2007-01-18 20:28:50 +00:00
parent ebc0de97f3
commit b7aff57102
2 changed files with 7 additions and 1 deletions

View file

@ -1,3 +1,7 @@
2007-01-18 Adam Fedor <fedor@gnu.org>
* Source/NSBitmapImageRep+PNM.m ([NSBitmapImageRep -_initBitmapFromPNM:errorMessage:]): Check for invalid image size.
2007-01-18 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSCell.m (-setFloatingPointFormat:left:right): Basic

View file

@ -98,8 +98,10 @@
GET_LINE();
} while (buffer[0] == '#');
num = sscanf(buffer, "%d %d", &xsize, &ysize);
if (num != 2)
if (num != 2 || xsize <= 0 || ysize <= 0)
ERRMSG(@"Invalid PNM header (xsize/ysize)");
if (xsize * ysize > (1 << 31))
ERRMSG(@"Invalid PNM header (image size:xsize*ysize too large)");
GET_LINE();
num = sscanf(buffer, "%d", &levels);
if (num != 1)