Fix PNG CRC calculation (doesn't include length for some reason...)

This commit is contained in:
Michael R Sweet 2021-06-10 11:02:55 -04:00
parent 466cb473d1
commit 2fbf9dc3b2
No known key found for this signature in database
GPG Key ID: BE67C75EC81F3244

View File

@ -1665,7 +1665,7 @@ copy_png(pdfio_dict_t *dict, // I - Dictionary
// Get the chunk length and type values...
length = (unsigned)((buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3]);
type = (unsigned)((buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7]);
crc = update_png_crc(0xffffffff, buffer, 8);
crc = update_png_crc(0xffffffff, buffer + 4, 4);
switch (type)
{
@ -1969,9 +1969,9 @@ copy_png(pdfio_dict_t *dict, // I - Dictionary
temp = (unsigned)((buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3]);
if (temp != crc)
{
// pdfioStreamClose(st);
pdfioStreamClose(st);
_pdfioFileError(dict->pdf, "Bad CRC (0x%08x != 0x%08x).", temp, crc);
// return (NULL);
return (NULL);
}
}