This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bug in gzip's stdout handling


Hi.

I run the latest version of cygwin, with gzip, on WindowsXP SP1 and have a
problem with gzip. The command

  $ cat binaryfile.bin | gzip -c > bin.gz

produces an invalid .gz file:

  $ gunzip bin.gz

  gunzip: bin.gz: invalid compressed data--crc error

  gunzip: bin.gz: invalid compressed data--length error

If I do

  gzip binaryfile.bin

everything works as expected - i.e. the resulting .gz file is valid.

If I do this instead:

  cat binaryfile.bin > acopy.bin

The two .bin files are identical.

My gzip version:

  $ gzip --version
  gzip 1.3.5
  (2002-09-30)
  Copyright 2002 Free Software Foundation
  Copyright 1992-1993 Jean-loup Gailly
  This program comes with ABSOLUTELY NO WARRANTY.
  You may redistribute copies of this program
  under the terms of the GNU General Public License.
  For more information about these matters, see the file named COPYING.
  Compilation options:
  DIRENT UTIME STDC_HEADERS HAVE_UNISTD_H HAVE_MEMORY_H HAVE_STRING_H
HAVE_LSTAT ASMV
  Written by Jean-loup Gailly.

My conclusion is that gzip's handling of stdout is broken in some way.


The reason I report this problem, instead of just avoiding it by not using
the -c option for gzip, is that I discovered the problem while running make
dist on a Makefile.in created by automake. And it's automake that creates
the gzip command line. I'll send a patch to the automake people and ask them
to fix this - but since it's really gzip that is broken, I think it should
be fixed here too.

I think you could fix this by setting the mode for the filehandle for stdout
to O_BINARY, i.e. something like this:

#if defined (_WIN32)
    setmode(FileHandle, O_BINARY);      /* Make sure it is in binary mode.
*/
#endif

It would be nice if you could look into it.

Best Regards,

Thomas Hammer
hammer@sim.no



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]