delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/02/18/12:28:40

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
From: "Juan Manuel Guerrero" <ST001906 AT HRZ1 DOT HRZ DOT TU-Darmstadt DOT De>
Organization: Darmstadt University of Technology
To: djgpp-workers AT delorie DOT com
Date: Mon, 18 Feb 2002 18:26:58 +0100
Subject: small djtar suggestion
X-mailer: Pegasus Mail for Windows (v2.54DE)
Message-ID: <248862B781E@HRZ1.hrz.tu-darmstadt.de>
Reply-To: djgpp-workers AT delorie DOT com

I do not know if this is of any interest but I have
noticed that djtar is not able to unzip zip files
created with older versions of WinZIP (6.3 SR-1, there may be others).
If the user runs the command:
  djtar -x *.zip
djtar will not unzip the file at all and also it will not
issue any warning or error massage telling the user the
reason why the zip file has not been unziped. Simply,
it silently returns to the dos prompt without doing anything.
This behaviour may lead a naive user to the assumption
that either djtar or the zip file is broken.
For some reason completely unknown to me, older versions
of WinZIP use the following magic header:
  \120\113\060\060\120\113\003\004 = PK00PK\3\4
instead of the usual one:
  \120\113\003\004 = PK\3\4
Info-ZIP and WinZIP for Win9X and Win31 are able to unzip such a file
without difficulty.
The patch below will solve this difficulty for djtar.

Regards,
Guerrero, Juan Manuel

Index: djgpp/src/utils/djtar/epunzip.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/utils/djtar/epunzip.c,v
retrieving revision 1.3
diff -u -r1.3 epunzip.c
--- djgpp/src/utils/djtar/epunzip.c	2001/09/19 03:54:06	1.3
+++ djgpp/src/utils/djtar/epunzip.c	2002/02/18 17:14:13
@@ -50,6 +50,7 @@
 	extra_length, should_be_written, count, real_file = 0;
       char filename[2048];
 
+continue_header_checking:
       ((char *)&buffer)[0] = (char)get_byte();
       ((char *)&buffer)[1] = (char)get_byte();
 
@@ -62,7 +63,14 @@
       ((char *)&buffer)[0] = (char)get_byte();
       ((char *)&buffer)[1] = (char)get_byte();
 
-      if(*(short *)&buffer != *(short *)"\3\4")
+      if(*(short *)&buffer == *(short *)"\60\60")
+	{
+	  /* Older WinZIP peograms generate zip files with a
+	     magic header byte sequence: \120\113\060\060\120\113\003\004
+	     instead of the usual sequence: \120\113\003\004. */
+	  goto continue_header_checking;
+	}
+      else if(*(short *)&buffer != *(short *)"\3\4")
 	{
 	  /* not a local header - all done */
 	  break;

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019