[diffoscope] 02/02: comparators.utils.file: Handle case where a file to be "fuzzy" matched does not contain enough entropy despite being over 512 bytes. (Closes: #882981)

Chris Lamb chris at chris-lamb.co.uk
Sat Dec 2 23:27:32 CET 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit 8599873025e9d71379f0ac5a7c5617b57c4c84a9
Author: Chris Lamb <lamby at debian.org>
Date:   Sat Dec 2 22:26:47 2017 +0000

    comparators.utils.file: Handle case where a file to be "fuzzy" matched does not contain enough entropy despite being over 512 bytes. (Closes: #882981)
---
 diffoscope/comparators/utils/file.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/diffoscope/comparators/utils/file.py b/diffoscope/comparators/utils/file.py
index 54ba9f4..e22ecd6 100644
--- a/diffoscope/comparators/utils/file.py
+++ b/diffoscope/comparators/utils/file.py
@@ -257,7 +257,11 @@ class File(object, metaclass=abc.ABCMeta):
                         for buf in iter(lambda: f.read(32768), b''):
                             h.update(buf)
                     h.final()
-                    self._fuzzy_hash = h.hexdigest()
+                    try:
+                        self._fuzzy_hash = h.hexdigest()
+                    except ValueError:
+                        # File must contain a certain amount of randomness.
+                        self._fuzzy_hash = None
                 else:
                     self._fuzzy_hash = None
             return self._fuzzy_hash

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list