[comp.sys.3b1] COMPRESS bug? Has this happened to YOU?

forrie@morwyn.UUCP (Forrie Aldrich) (04/16/91)

I have had, a few times, an interesting thing happen to me when using
this newer version of compress:

$Header: compress.c,v 4.0 85/07/30 12:50:00 joe Release $
Options: BITS = 16

When I am in the middle of 'zcat'ing a file, and I stop/interrupt, suddenly
the file I was looking at disappears and is gone without a trace.

Can anyone explain why this is so?  I think I will revert back to the older
version of compress that I had, as I never had problems with it.

Thanks,

Forrie

PS:  I snarfed this version of compress from the gnu archives on
prep.ai.mit.edu ...

-- 

--------------------=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--------------------
Forrest Aldrich, Jr.|   ...uunet!eci!morwyn!forrie       |forrie@morywn.UUCP
                    |          <email paths>             | 
CREATIVE CONNECTIONS|  ...uunet!zinn!eci!morwyn!forrie   |Graphic Illustration
------------------\-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=/------------------
                   \___ PO Box 1541 - Dover, NH  03820 ___/                   

res@colnet.uucp (Rob Stampfli) (04/17/91)

In article <82@morwyn.UUCP> forrie@morwyn.UUCP (Forrie Aldrich) writes:
>
>When I am in the middle of 'zcat'ing a file, and I stop/interrupt, suddenly
>the file I was looking at disappears and is gone without a trace.
>
I fixed these bugs a long time ago and posted the mods to the net.  If
anyone wants them, let me know.
-- 
Rob Stampfli, 614-864-9377, res@kd8wk.uucp (osu-cis!kd8wk!res), kd8wk@n8jyv.oh

bdb@becker.UUCP (Bruce D. Becker) (04/23/91)

In article <82@morwyn.UUCP> forrie@morwyn.UUCP (Forrie Aldrich) writes:
|I have had, a few times, an interesting thing happen to me when using
|this newer version of compress:
|
|$Header: compress.c,v 4.0 85/07/30 12:50:00 joe Release $
|Options: BITS = 16
|
|When I am in the middle of 'zcat'ing a file, and I stop/interrupt, suddenly
|the file I was looking at disappears and is gone without a trace.
|
|Can anyone explain why this is so?  I think I will revert back to the older
|version of compress that I had, as I never had problems with it.
|
|PS:  I snarfed this version of compress from the gnu archives on
|prep.ai.mit.edu ...

	Here's a repost of a fix for this...

 --------- 8< --------- 8< --------- 8< --------- 8< --------- 8< ---------

From: stu@gtisqr.uucp (Stu Donaldson)
Newsgroups: comp.sources.bugs,comp.sources.d
Subject: Bug in compress 4.0 (zcat)
Keywords: compress
Message-ID: <1990Sep14.201714.12849@gtisqr.uucp>
Date: 14 Sep 90 20:17:14 GMT
Followup-To: comp.sources.bugs
Organization: Maverick Microsystems International Inc, Mukilteo WA.
Lines: 80

Here is a patch to fix a bug I found in compress (zcat).  

The problem would occur when trying to zcat a file that was the maximum
length filename, and didn't have the .Z stuck on the end.  These files
would often be created by transferring compressed files from BSD systems
to a System V system which would truncate the name to 14 chars.

When processing the filenames, compress leaves the variable ofname with
the standard output filename format of a file. 

Thus, when doing a 'zcat abc.Z', the variable ofname would be 'abc'. 

This is just fine unless the input filename is 'abcdefghijklmn' 
(the '.Z' truncated off is truncated on System V). 
Now ofname="abcdefghijklmn" which is also the input filename. 

If compress encounters an error during it's operation, or an interrupt, 
it will try to unlink(ofname) which in the case described above, will 
remove the file you were trying to look at.

My solution was to not unlink the output file on errors if doing a zcat.

================================================================
*** ../y/compress.c	Fri Sep 14 09:41:40 1990
--- compress.c	Fri Sep 14 09:23:29 1990
***************
*** 1264,1270 ****
  writeerr()
  {
      perror ( ofname );
!     unlink ( ofname );
      exit ( 1 );
  }
  
--- 1264,1270 ----
  writeerr()
  {
      perror ( ofname );
!     if (zcat_flg == 0) unlink ( ofname );
      exit ( 1 );
  }
  
***************
*** 1333,1339 ****
  
  onintr ( )
  {
!     unlink ( ofname );
      exit ( 1 );
  }
  
--- 1333,1339 ----
  
  onintr ( )
  {
!     if (zcat_flg == 0) unlink ( ofname );
      exit ( 1 );
  }
  
***************
*** 1341,1347 ****
  {
      if ( do_decomp == 1 ) 
      	fprintf ( stderr, "uncompress: corrupt input\n" );
!     unlink ( ofname );
      exit ( 1 );
  }
  
--- 1341,1347 ----
  {
      if ( do_decomp == 1 ) 
      	fprintf ( stderr, "uncompress: corrupt input\n" );
!     if (zcat_flg == 0) unlink ( ofname );
      exit ( 1 );
  }
--
Stu Donaldson          UUCP: {smart-host}!gtisqr!stu
Maverick Microsystems  ARPA: gtisqr!stu@yang.cpac.washington.edu
Mukilteo, Washington   Bell: (206) 743-6659
  


-- 
  ,u,	 Bruce Becker	Toronto, Ontario
a /i/	 Internet: bdb@becker.UUCP, bruce@gpu.utcs.toronto.edu
 `\o\-e	 UUCP: ...!utai!mnetor!becker!bdb
 _< /_	 "Waking up is hard to do" - Neil Sedated