KZip: cannot read small ZIP files

Nicolas Goutte nicog at snafu.de
Tue Dec 10 14:32:31 GMT 2002


Attached is a patch for the file kdelibs/kio/kio/kzip.cpp (for KDE_3_1_BRANCH)

The patch solves the problem that some files created by zip could not be 
opened. It also changes three similar kdWarnings to separate one from the 
other.

The problem was that a test used a boolean and (&&) instead of a bit-wise and 
(&)

I cannot test if OpenOffice's ZIP files are still read correctly after this 
patch.

I can commit the patch to the KDE_3_1_BRANCH but somebody should port it to 
HEAD please. Thank you in advance!

Have a nice day/evening/night!
-------------- next part --------------
Index: kzip.cpp
===================================================================
RCS file: /home/kde/kdelibs/kio/kio/kzip.cpp,v
retrieving revision 1.20
diff -u -r1.20 kzip.cpp
--- kzip.cpp	19 Nov 2002 12:08:27 -0000	1.20
+++ kzip.cpp	10 Dec 2002 14:25:50 -0000
@@ -172,7 +172,7 @@
 
         if (n < 4)
         {
-            kdWarning(7040) << "Invalid ZIP file. Unexpected end of file." << endl;
+            kdWarning(7040) << "Invalid ZIP file. Unexpected end of file. (#1)" << endl;
 
             return false;
         }
@@ -189,7 +189,7 @@
             // the file and we look for the signature 'PK\7\8'.
 
             dev->readBlock( buffer, 2 );
-            if ( buffer[0] && 8 )
+            if ( buffer[0] & 8 )
             {
                 bool foundSignature = false;
 
@@ -198,7 +198,7 @@
                     n = dev->readBlock( buffer, 1 );
                     if (n < 1)
                     {
-                        kdWarning(7040) << "Invalid ZIP file. Unexpected end of file." << endl;
+                        kdWarning(7040) << "Invalid ZIP file. Unexpected end of file. (#2)" << endl;
                         return false;
                     }
 
@@ -208,7 +208,7 @@
                     n = dev->readBlock( buffer, 3 );
                     if (n < 3)
                     {
-                        kdWarning(7040) << "Invalid ZIP file. Unexpected end of file." << endl;
+                        kdWarning(7040) << "Invalid ZIP file. Unexpected end of file. (#3)" << endl;
                         return false;
                     }
 


More information about the kde-core-devel mailing list