+
+extern void check_trailer_gzip(int src_fd)
+{
+ unsigned int stored_crc = 0;
+ unsigned char count;
+
+ /* top up the input buffer with the rest of the trailer */
+ count = bytebuffer_size - bytebuffer_offset;
+ if (count < 8) {
+ xread_all(src_fd, &bytebuffer[bytebuffer_size], 8 - count);
+ bytebuffer_size += 8 - count;
+ }
+ for (count = 0; count != 4; count++) {
+ stored_crc |= (bytebuffer[bytebuffer_offset] << (count * 8));
+ bytebuffer_offset++;
+ }
+
+ /* Validate decompression - crc */
+ if (stored_crc != (gunzip_crc ^ 0xffffffffL)) {
+ error_msg_and_die("crc error");
+ }
+
+ /* Validate decompression - size */
+ if (gunzip_bytes_out !=
+ (bytebuffer[bytebuffer_offset] | (bytebuffer[bytebuffer_offset+1] << 8) |
+ (bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) {
+ error_msg_and_die("Incorrect length, but crc is correct");
+ }
+
+}