[Git][reproducible-builds/diffoscope][master] Fix FIT image detection for larger image files. (MR: reproducible-builds/diffoscope!75)

Chris Lamb gitlab at salsa.debian.org
Thu Jan 28 10:10:07 UTC 2021



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
74ca80df by Conrad Ratschan at 2021-01-28T10:09:06+00:00
Fix FIT image detection for larger image files. (MR: reproducible-builds/diffoscope!75)

Use manual magic comparison for FIT images (device tree blob) to work
around a bug in libmagic that results in device tree blob files not
correctly being identified when the structure section is larger than 1MB.

libmagic bug report: https://bugs.astron.com/view.php?id=232

Signed-off-by: Chris Lamb <lamby at debian.org>

- - - - -


1 changed file:

- diffoscope/comparators/fit.py


Changes:

=====================================
diffoscope/comparators/fit.py
=====================================
@@ -96,12 +96,13 @@ class FlattenedImageTreeFile(File):
     """
 
     DESCRIPTION = "Flattened Image Tree blob files"
-    FILE_TYPE_RE = re.compile(r"^Device Tree Blob")
     CONTAINER_CLASSES = [FitContainer]
 
     @classmethod
     def recognizes(cls, file):
-        if not cls.FILE_TYPE_RE.search(file.magic_file_type):
+        # Detect file magic manually to workaround incorrect detection of devicetree
+        # by libmagic when the devicetree structure section is larger than 1MB
+        if file.file_header[:4] != b"\xd0\x0d\xfe\xed":
             return False
 
         if not tool_check_installed("fdtdump"):



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

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/74ca80dfc9517a0ecb0b7f0442fa4493f42b3b8e
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/20210128/2b64765c/attachment.htm>


More information about the rb-commits mailing list