}
/* if we havent read the header before, set the header data */
- E_FREAD(buf, 1, PNG_BYTES_TO_CHECK, f);
+ if (E_FREAD(buf, 1, PNG_BYTES_TO_CHECK, f) != 1)
+ {
+ *error = EVAS_LOAD_ERROR_CORRUPT_FILE;
+ goto close_file;
+ }
if (png_sig_cmp(buf, 0, PNG_BYTES_TO_CHECK))
{
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
return EINA_FALSE;
}
- fread(&magic_number, sizeof(uint16), 1, ffile);
+ if (fread(&magic_number, sizeof(uint16), 1, ffile) != 1)
+ {
+ fclose(ffile);
+ *error = EVAS_LOAD_ERROR_CORRUPT_FILE;
+ return EINA_FALSE;
+ }
/* Apparently rewind(f) isn't sufficient */
fseek(ffile, (long)0, SEEK_SET);
&& (magic_number != TIFF_LITTLEENDIAN))
{
fclose(ffile);
- *error = EVAS_LOAD_ERROR_GENERIC;
+ *error = EVAS_LOAD_ERROR_CORRUPT_FILE;
return EINA_FALSE;
}