🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.bugs
Article #426

Bug in compress 4.0 (zcat)

#426
From: Stu Donaldson
Date: Fri, 14 Sep 1990 20:17
80 lines
2707 bytes
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
  
Technical Details
Message-ID: <1990Sep14.201714.12849@gtisqr.uucp>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!uw-beaver!fluke!gtisqr!stu

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!uw-beaver!fluke!gtisqr!stu
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