SGI: sanitize input data

Refuse nonsensical xsize, ysize, zsize values.
This commit is contained in:
Nils Philippsen
2009-12-09 15:43:28 +01:00
parent 5aa82f3b6d
commit daaf1d2b97

View File

@ -334,6 +334,28 @@ load_image (const gchar *filename,
* Get the image dimensions and create the image...
*/
/* Sanitize dimensions */
if (sgip->xsize == 0 || sgip->xsize > GIMP_MAX_IMAGE_SIZE)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Invalid width: %hu"), sgip->xsize);
return -1;
}
if (sgip->ysize == 0 || sgip->ysize > GIMP_MAX_IMAGE_SIZE)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Invalid height: %hu"), sgip->ysize);
return -1;
}
if (sgip->zsize == 0 || sgip->zsize > GIMP_MAX_IMAGE_SIZE)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Invalid number of channels: %hu"), sgip->zsize);
return -1;
}
bytes = sgip->zsize;
switch (sgip->zsize)