diff options
author | Helmut Grohne <helmut@subdivi.de> | 2014-02-19 07:54:21 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2014-02-19 07:54:21 +0100 |
commit | 17597b5e828f9bbc9b0159102b173c284c23a140 (patch) | |
tree | 2d50885299960379bc09a22d6154a39f67748c4d | |
parent | d228c0a4a5827325bca47d63ea287c7cb56537ea (diff) | |
download | debian-dedup-17597b5e828f9bbc9b0159102b173c284c23a140.tar.gz |
DecompressedHash should fail on trailing input
Otherwise all files smaller than 10 bytes are successfully hashed to the
hash of the empty input when using the GzipDecompressor.
Reported-By: Olly Betts
-rw-r--r-- | dedup/hashing.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/dedup/hashing.py b/dedup/hashing.py index 002eda8..5f015b2 100644 --- a/dedup/hashing.py +++ b/dedup/hashing.py @@ -49,9 +49,13 @@ class DecompressedHash(object): def hexdigest(self): if not hasattr(self.decompressor, "flush"): + if self.decompressor.unused_data: + raise ValueError("decompressor did not consume all data") return self.hashobj.hexdigest() tmpdecomp = self.decompressor.copy() data = tmpdecomp.flush() + if tmpdecomp.unused_data: + raise ValueError("decompressor did not consume all data") tmphash = self.hashobj.copy() tmphash.update(data) return tmphash.hexdigest() |