--- pgp/src/zfile_io.c 2018/04/24 16:37:53 1.1.1.1 +++ pgp/src/zfile_io.c 2018/04/24 16:41:11 1.1.1.4 @@ -13,6 +13,7 @@ #include "zunzip.h" +#if 0 /****************************/ /* Function FillBitBuffer() */ /****************************/ @@ -49,19 +50,54 @@ UWORD *x; if (csize-- <= 0) - return 0; + return 0; if (incnt == 0) { - if ((incnt = read(zipfd, inbuf, INBUFSIZ)) <= 0) - return 0; - /* buffer ALWAYS starts on a block boundary: */ - inptr = inbuf; + if ((incnt = read(zipfd, (char *) inbuf, INBUFSIZ)) <= 0) + return 0; + /* buffer ALWAYS starts on a block boundary: */ + inptr = inbuf; } *x = *inptr++; --incnt; return 8; } +#else +/* + * This function is used only by the NEEDBYTE macro in inflate.c. + * It fills the buffer and resets the count and pointers for the + * macro to resume processing. The count is set to the number of bytes + * read in minus one, while the pointer is set to the beginning of the + * buffer. This is all to make the macro more efficient. + * + * In exceptional circumstances, zinflate can read a byte or two past the + * end of input, so we allow this for a little bit before returning + * an error. zinflate doesn't actually use the bytes, so the value + * is irrelevant. + * + * Returns 0 on success, non-zero on error. + */ +int FillInBuf() +{ + static int eofonce = 0; + + incnt = read(zipfd, (char *)inbuf, INBUFSIZ); + + if (incnt > 0) { /* Read went okay */ + inptr = inbuf; + --incnt; + return 0; + } else if (incnt == 0 && !eofonce) { /* Special fudge case */ + eofonce++; + incnt = 2; + inptr = inbuf; + return 0; + } else { /* Error */ + return 1; + } +} +#endif /**************************/ /* Function FlushOutput() */ @@ -76,7 +112,7 @@ int FlushOutput() if (outcnt) { len = outcnt; - if (write(outfd, outout, len) != len) + if (write(outfd, (char *) outout, len) != len) #ifdef MINIX if (errno == EFBIG) if (write(fd, outout, len/2) != len/2 ||