61f13b9ac5
until a workable 2008 packages and environment is ready.
39 lines
1.3 KiB
Diff
39 lines
1.3 KiB
Diff
Index: pisi/archive.py
|
|
===================================================================
|
|
--- pisi/archive.py (revision 16476)
|
|
+++ pisi/archive.py (working copy)
|
|
@@ -19,6 +19,7 @@
|
|
import tarfile
|
|
import zipfile
|
|
import gzip
|
|
+import struct
|
|
|
|
import gettext
|
|
__trans = gettext.translation('pisi', fallback=True)
|
|
@@ -212,8 +213,24 @@
|
|
"Attempt to read ZIP archive that was already closed"
|
|
zinfo = self.getinfo(name)
|
|
filepos = self.fp.tell()
|
|
- self.fp.seek(zinfo.file_offset, 0)
|
|
|
|
+ self.fp.seek(zinfo.header_offset, 0)
|
|
+
|
|
+ # Skip the file header:
|
|
+ fheader = self.fp.read(30)
|
|
+ if fheader[0:4] != zipfile.stringFileHeader:
|
|
+ raise BadZipfile, "Bad magic number for file header"
|
|
+
|
|
+ fheader = struct.unpack(zipfile.structFileHeader, fheader)
|
|
+ fname = self.fp.read(fheader[zipfile._FH_FILENAME_LENGTH])
|
|
+ if fheader[zipfile._FH_EXTRA_FIELD_LENGTH]:
|
|
+ self.fp.read(fheader[zipfile._FH_EXTRA_FIELD_LENGTH])
|
|
+
|
|
+ if fname != zinfo.orig_filename:
|
|
+ raise zipfile.BadZipfile, \
|
|
+ 'File name in directory "%s" and header "%s" differ.' % (
|
|
+ zinfo.orig_filename, fname)
|
|
+
|
|
destfile = file(outname, 'wb')
|
|
|
|
if zinfo.compress_type == zipfile.ZIP_STORED:
|