[yum-commits] Branch 'yum-3_2_X' - yum/misc.py
James Antill
james at osuosl.org
Fri Sep 25 19:54:26 UTC 2009
yum/misc.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
New commits:
commit a464c00c1ab1b3909bfbcc6c98415c8284ccfa72
Author: James Antill <james at and.org>
Date: Fri Sep 25 14:23:05 2009 -0400
Fail the checksum size checks on undersized, as well as oversized, data
diff --git a/yum/misc.py b/yum/misc.py
index 9793180..16ffca0 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -293,7 +293,8 @@ def checksum(sumtype, file, CHUNK=2**16, datasize=None):
data = Checksums([sumtype])
while data.read(fo, CHUNK):
- pass
+ if datasize is not None and len(data) > datasize:
+ break
if type(file) is types.StringType:
fo.close()
@@ -301,7 +302,7 @@ def checksum(sumtype, file, CHUNK=2**16, datasize=None):
# This screws up the length, but that shouldn't matter. We only care
# if this checksum == what we expect.
- if datasize is not None and datasize > len(data):
+ if datasize is not None and datasize != len(data):
return '!%u!%s' % (datasize, data.hexdigest(sumtype))
return data.hexdigest(sumtype)
More information about the Yum-commits
mailing list