|
|
fread(dbuf, 4, 2, file); | fread(dbuf, 4, 2, file); |
*w = (int)dbuf[0]; | *w = (int)dbuf[0]; |
*h = (int)dbuf[1]; | *h = (int)dbuf[1]; |
if (*w > 32767) |
if ((*w < 0) || (*w > 32767)) |
{ | { |
fprintf(stderr, "IMLIB ERROR: Image width > 32767 pixels for file\n"); | fprintf(stderr, "IMLIB ERROR: Image width > 32767 pixels for file\n"); |
return NULL; | return NULL; |
} | } |
if (*h > 32767) |
if ((*h > 32767) || (*h < 0)) |
{ | { |
fprintf(stderr, "IMLIB ERROR: Image height > 32767 pixels for file\n"); | fprintf(stderr, "IMLIB ERROR: Image height > 32767 pixels for file\n"); |
return NULL; | return NULL; |
|
|
ncolors = (int)dbuf[0]; | ncolors = (int)dbuf[0]; |
if (ncolors == 0) | if (ncolors == 0) |
ncolors = 1 << bpp; | ncolors = 1 << bpp; |
|
|
|
if ((ncolors > (1 << bpp)) || (ncolors < 0)) |
|
ncolors = 1 << bpp; |
|
|
/* some more sanity checks */ | /* some more sanity checks */ |
if (((comp == BI_RLE4) && (bpp != 4)) || ((comp == BI_RLE8) && (bpp != 8)) || ((comp == BI_BITFIELDS) && (bpp != 16 && bpp != 32))) | if (((comp == BI_RLE4) && (bpp != 4)) || ((comp == BI_RLE8) && (bpp != 8)) || ((comp == BI_BITFIELDS) && (bpp != 16 && bpp != 32))) |
{ | { |