Package: zlib Version: 1.2.3.3.dfsg-7 When reading uncompressed files with gzread() the EOF indicator is not always set correctly. The EOF indicator is only set, when the underlying fread() returned 0. This is incorrect, since any return value that is shorter than the nmemb argument may indicate an EOF. The correct behavior is to explicitly check feof() after the fread() determine whether EOF occored. An example that triggers this bug is:
rc = gzread(zfp, buf, 256); if (rc < 256) { if (gzeof(zfp)) printf("Had EOF"); else prinf("Not EOF, but short byte count returned"); } If rc!=0 and <256, gzeof() will never indicate and EOF, even if underlying fread() reported an EOF. The attached patch fixes this problem (second chunk in the patch). The patch also fixes another (small) EOF glitch in check_headers, that is not really a bug, but an 'ugly' way of doing things. (First chunk in the patch). cu Gregor -- Gregor Maier [EMAIL PROTECTED] TU Berlin / Deutsche Telekom Labs [EMAIL PROTECTED] Sekr. TEL 4, FG INET www.net.t-labs.tu-berlin.de Ernst-Reuter-Platz 7 10587 Berlin, Germany
diff -Naur zlib-1.2.3.3.dfsg.orig/gzio.c zlib-1.2.3.3.dfsg/gzio.c --- zlib-1.2.3.3.dfsg.orig/gzio.c 2007-11-28 18:58:24.000000000 +0100 +++ zlib-1.2.3.3.dfsg/gzio.c 2007-11-28 19:18:25.000000000 +0100 @@ -339,7 +339,7 @@ if (len) s->inbuf[0] = s->stream.next_in[0]; errno = 0; len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file); - if (len == 0) s->z_eof = 1; + if (len == 0 && feof(s->file)) s->z_eof = 1; if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO; s->stream.avail_in += len; s->stream.next_in = s->inbuf; @@ -482,7 +482,7 @@ len -= s->stream.avail_out; s->in += len; s->out += len; - if (len == 0) s->z_eof = 1; + if (feof(s->file)) s->z_eof = 1; return (int)len; } if (s->stream.avail_in == 0 && !s->z_eof) {
signature.asc
Description: OpenPGP digital signature