Salut Olivier,
Olivier Taibi wrote on Wed, Apr 15, 2020 at 07:52:21PM +0200:
> I believe there is a bug in gzopen(3) when opening an empty file. It
> can read both gzipped and uncompressed files, and obviously an empty
> file falls in the second category, but in this case the first read gives
> a buffer error (Z_BUF_ERROR in zlib.h) instead of EOF (Z_STREAM_END in
> zlib.h) because the stream is incorrectly identified as gzipped. The
> following diff fixes this issue for me.
Thanks for noticing, analyzing, reporting, and fixing the bug.
I just committed your patch.
Yours,
Ingo
> Index: gzio.c
> ===================================================================
> RCS file: /cvs/src/lib/libz/gzio.c,v
> retrieving revision 1.14
> diff -u -p -u -p -r1.14 gzio.c
> --- gzio.c 20 Jul 2005 15:56:41 -0000 1.14
> +++ gzio.c 15 Apr 2020 12:54:37 -0000
> @@ -307,7 +307,7 @@ local void check_header(s)
> s->stream.avail_in += len;
> s->stream.next_in = s->inbuf;
> if (s->stream.avail_in < 2) {
> - s->transparent = s->stream.avail_in;
> + s->transparent = 1;
> return;
> }
> }