Fossil SCM

osx will not unzip the zip files created by fossil

Fixed

923a9123096ae70… · opened 16 years, 8 months ago

Type
Incident
Priority
Severity
Important
Resolution
Fixed
Subsystem
Created
July 13, 2009 12:27 p.m.

osx will not unzip the zip files created by fossil

to replicate the problem ;

  1. login as anonymous to fossil-scm.org

  2. choose either timeline or leaves

  3. click on a 'version'(?) to open the summary page

  4. click on 'ZIP archive' to start download.

  5. download completed; either

    a) choose unzip as the default action, or

    b) double-click from finder.

(behaviour noted in osx 10.5)


drh added on 2009-07-13 14:13:50:
This is a known problem. If you run "unzip" from the command-line it works.
But if you double-click on the icon it does not. I have no idea what the difference is and since I don't have source code to Apple's unzip utility, I cannot run it in a debugger to find out. Any suggestions on how to proceed are welcomed.


anonymous added on 2009-07-16 22:48:57:
The bug exists within ditto, the utility that BOMArchiver (the graphical front-end for zip extraction on OS X) uses. The error reporting on the Console is "Couldn't read pkzip signature." A quick investigation reveals that this occurs when the data descriptor flag is set (see http://www.info-zip.org/board/board.pl?m-1198023427/). However, a quick overview of Fossil's zip files doesn't appear to indicate that this bit is set, so I'm at a loss.


anonymous claiming to be Dmitry Chestnykh added on 2009-10-18 15:31:44:
If we use deflateInit2 instead of deflateInit, zlib will not append Adler32 CRC to the end of compressed stream, and also it will not prepend 2-byte signature to the beginning of compressed stream.

This fixes the issue with ditto.

(As discussed here)


--- src/zip.c
+++ src/zip.c
@@ -126,11 +126,10 @@
 ** that the file should be saved as.
 */
 void zip_add_file(const char *zName, const Blob *pFile){
   z_stream stream;
   int nameLen;
-  int skip;
   int toOut;
   int iStart;
   int iCRC = 0;
   int nByte = 0;
   int nByteCompr = 0;
@@ -177,53 +176,37 @@
   blob_append(&body, zHdr, 30);
   blob_append(&body, zName, nameLen);
   blob_append(&body, zExTime, 13);

   if( nBlob>0 ){
-    /* The first two bytes that come out of the deflate compressor are
-    ** some kind of header that ZIP does not use.  So skip the first two
-    ** output bytes.
-    */
-    skip = 2;
-
     /* Write the compressed file.  Compute the CRC as we progress.
     */
     stream.zalloc = (alloc_func)0;
     stream.zfree = (free_func)0;
     stream.opaque = 0;
     stream.avail_in = blob_size(pFile);
     stream.next_in = (unsigned char*)blob_buffer(pFile);
     stream.avail_out = sizeof(zOutBuf);
     stream.next_out = (unsigned char*)zOutBuf;
-    deflateInit(&stream, 9);
+    deflateInit2(&stream, 9, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY);
     iCRC = crc32(0, stream.next_in, stream.avail_in);
     while( stream.avail_in>0 ){
       deflate(&stream, 0);
       toOut = sizeof(zOutBuf) - stream.avail_out;
-      if( toOut>skip ){
-        blob_append(&body, &zOutBuf[skip], toOut - skip);
-        skip = 0;
-      }else{
-        skip -= toOut;
-      }
+      blob_append(&body, zOutBuf, toOut);
       stream.avail_out = sizeof(zOutBuf);
       stream.next_out = (unsigned char*)zOutBuf;
     }
     do{
       stream.avail_out = sizeof(zOutBuf);
       stream.next_out = (unsigned char*)zOutBuf;
       deflate(&stream, Z_FINISH);
       toOut = sizeof(zOutBuf) - stream.avail_out;
-      if( toOut>skip ){
-        blob_append(&body, &zOutBuf[skip], toOut - skip);
-        skip = 0;
-      }else{
-        skip -= toOut;
-      }
+      blob_append(&body, zOutBuf, toOut);
     }while( stream.avail_out==0 );
     nByte = stream.total_in;
-    nByteCompr = stream.total_out - 2;
+    nByteCompr = stream.total_out;
     deflateEnd(&stream);

     /* Go back and write the header, now that we know the compressed file size.
     */
     z = &blob_buffer(&body)[iStart];

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button