@@ -1682,6 +1682,7 @@ cups_fill(cups_file_t *fp) // I - CUPS file
16821682
16831683 if (fp -> stream .avail_in > 0 )
16841684 {
1685+ // Get the first N trailer bytes from the inflate stream...
16851686 if (fp -> stream .avail_in > sizeof (trailer ))
16861687 tbytes = (ssize_t )sizeof (trailer );
16871688 else
@@ -1692,6 +1693,12 @@ cups_fill(cups_file_t *fp) // I - CUPS file
16921693 fp -> stream .avail_in -= (size_t )tbytes ;
16931694 }
16941695
1696+ // Reset the compressed flag so that we re-read the file header...
1697+ inflateEnd (& fp -> stream );
1698+
1699+ fp -> compressed = false;
1700+
1701+ // Get any remaining trailer bytes...
16951702 if (tbytes < (ssize_t )sizeof (trailer ))
16961703 {
16971704 if (read (fp -> fd , trailer + tbytes , sizeof (trailer ) - (size_t )tbytes ) < ((ssize_t )sizeof (trailer ) - tbytes ))
@@ -1704,6 +1711,7 @@ cups_fill(cups_file_t *fp) // I - CUPS file
17041711 }
17051712 }
17061713
1714+ // Calculate and compare the CRC...
17071715 tcrc = ((((((uLong )trailer [3 ] << 8 ) | (uLong )trailer [2 ]) << 8 ) | (uLong )trailer [1 ]) << 8 ) | (uLong )trailer [0 ];
17081716
17091717 if (tcrc != fp -> crc )
@@ -1714,11 +1722,6 @@ cups_fill(cups_file_t *fp) // I - CUPS file
17141722
17151723 return (-1 );
17161724 }
1717-
1718- // Otherwise, reset the compressed flag so that we re-read the file header...
1719- inflateEnd (& fp -> stream );
1720-
1721- fp -> compressed = false;
17221725 }
17231726 else if (status < Z_OK )
17241727 {
0 commit comments