[Git][reproducible-builds/diffoscope][master] Fix a crash when there are (invalid) duplicate entries in .zip files. (Closes: Debian:#1068705)

Chris Lamb (@lamby) gitlab at salsa.debian.org
Thu Apr 11 10:09:45 UTC 2024



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
945fd9fa by Fay Stegerman at 2024-04-11T11:09:16+01:00
Fix a crash when there are (invalid) duplicate entries in .zip files. (Closes: Debian:#1068705)

- - - - -


1 changed file:

- diffoscope/comparators/zip.py


Changes:

=====================================
diffoscope/comparators/zip.py
=====================================
@@ -182,7 +182,12 @@ class ZipDirectory(Directory, ArchiveMember):
 
 class ZipContainer(Archive):
     def open_archive(self):
-        return zipfile.ZipFile(self.source.path, "r")
+        zf = zipfile.ZipFile(self.source.path, "r")
+        self.name_to_info = {}
+        for info in zf.infolist():
+            if info.filename not in self.name_to_info:
+                self.name_to_info[info.filename] = info
+        return zf
 
     def close_archive(self):
         self.archive.close()
@@ -199,7 +204,8 @@ class ZipContainer(Archive):
         ).encode(sys.getfilesystemencoding(), errors="replace")
 
         try:
-            with self.archive.open(member_name) as source, open(
+            info = self.name_to_info[member_name]
+            with self.archive.open(info) as source, open(
                 targetpath, "wb"
             ) as target:
                 shutil.copyfileobj(source, target)



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/945fd9faed3ae48d5f16602db1eb037c4785aeb5

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/945fd9faed3ae48d5f16602db1eb037c4785aeb5
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20240411/161c27e3/attachment.htm>


More information about the rb-commits mailing list