Summary: | KZip produces invalid ZIP files | ||
---|---|---|---|
Product: | [Frameworks and Libraries] kio | Reporter: | Nicolas Goutte <nicolasg> |
Component: | general | Assignee: | David Faure <faure> |
Status: | CLOSED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: |
Error returning by zip
kzip_cpp.diff Patch |
Description
Nicolas Goutte
2003-04-01 02:20:11 UTC
Created attachment 1281 [details]
Error returning by zip
The error can be created by saving an empty KWord file as test.kwd
Then:
touch test
zip test.kwd test
This gives the error.
Subject: New: KZip produces invalid ZIP files Attached is a patch for kdelibs/kio/kio/kzip.cpp (KDE_3_1_BRANCH) The problem seems that the general purpose bit flag needs to be NULL, even at the 4th bit. If the 5th bit is set, zip seems to want extra data, which we do not have/give. I have checked that KWord saves and load, zip can add a new file, unzip works. (However kziptest seems to fail.) Someone would need to port this to KDE CVS HEAD. Have a nice day/evening/night! Created an attachment (id=1292) kzip_cpp.diff Subject: New: KZip produces invalid ZIP files I have made an error and now kziptest (readwrite) works correctly. (I was runnig kziptest KDE 3.1.x against KDE 3.0 (as I was running KMail)) Have a nice day/evening/night! Subject: Re: KZip produces invalid ZIP files
On Wednesday 02 April 2003 16:07, you wrote:
> --> (http://bugs.kde.org/attachment.cgi?id=1292&action=view)
I'm afraid this attachment is empty.
Does this mean Holger's first patch works?
Feel free to commit once it works for you, anyway.
Created attachment 1293 [details]
Patch
(Now I have uploaded the patch instead of mailing it.) No, Holger's patch is wrong. What needs to be done is exactly the opposite of what I thought first. Have a nice day/evening/night! Subject: Re: KZip produces invalid ZIP files
On Wednesday 02 April 2003 18:55, you wrote:
> What needs to be done is exactly the opposite of what I thought first.
Ah ok. Well I can't help here. Either commit or mail Holger...
Subject: Re: New: KZip produces invalid ZIP files Good, now I think that I understand better the problem. I looked at bit 4 but 8=2^3. But bit 3 is the variant that put zero to sies and CRC and gives these sizes in an extra local header at the end of the file data. So if I remember well, we do not write in these mode. So my patch should be right (and now I understand why and the reason of zip reactions.) I am going to commit. Have a nice day/evening/night! On Wednesday 02 April 2003 16:08, Nicolas Goutte wrote: > Attached is a patch for kdelibs/kio/kio/kzip.cpp (KDE_3_1_BRANCH) > > The problem seems that the general purpose bit flag needs to be NULL, even > at the 4th bit. If the 5th bit is set, zip seems to want extra data, which > we do not have/give. > > I have checked that KWord saves and load, zip can add a new file, unzip > works. (However kziptest seems to fail.) > > Someone would need to port this to KDE CVS HEAD. > > Have a nice day/evening/night! Subject: KDE_3_1_BRANCH: kdelibs/kio/kio CVS commit by goutte: Write out correctly ZIP's general purpose bit flag (We write the sizes and the CRC directly in the local header. We do not need to tell that we are "delaying" this information.) CCMAIL:56682@bugs.kde.org M +3 -5 kzip.cpp 1.20.2.3 --- kdelibs/kio/kio/kzip.cpp #1.20.2.2:1.20.2.3 @@ -461,9 +461,7 @@ bool KZip::closeArchive() qmemmove(buffer, head, sizeof(head)); - if ( it.current()->encoding() == 8 ) - { - buffer[ 8 ] = 8, // general purpose bit flag, deflated - buffer[ 10 ] = 8; // compression method, deflated - } + buffer[ 10 ] = char(it.current()->encoding()); // compression method + buffer[ 11 ] = char(it.current()->encoding() >> 8); + transformToMsDos( it.current()->datetime(), &buffer[ 12 ] ); Subject: kdelibs/kio/kio CVS commit by goutte: Write out correctly the general purpose bit flag (We are writing the sizes and the CRC in the local header and not at the end of each file. (Bit 3)) (Forward-port, not tested) CCMAIL:56682-close@bugs.kde.org M +3 -6 kzip.cpp 1.32 --- kdelibs/kio/kio/kzip.cpp #1.31:1.32 @@ -724,9 +724,6 @@ bool KZip::closeArchive() qmemmove(buffer, head, sizeof(head)); - if ( it.current()->encoding() == 8 ) - { - buffer[ 8 ] = 8, // general purpose bit flag, deflated - buffer[ 10 ] = 8; // compression method, deflated - } + buffer[ 10 ] = char(it.current()->encoding()); // compression method + buffer[ 11 ] = char(it.current()->encoding() >> 8); transformToMsDos( it.current()->datetime(), &buffer[ 12 ] ); |