diff options
author | Georg Brandl <georg@python.org> | 2006-12-20 11:55:16 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-12-20 11:55:16 (GMT) |
commit | ded1c4df0b98b05af22d82bd8ae8795f7c8da916 (patch) | |
tree | 279ed70caa94a6e534ac1318b024ed73a06a5656 /Lib/tarfile.py | |
parent | 94547f7646895e032f8fc145529d9efc3a70760d (diff) | |
download | cpython-ded1c4df0b98b05af22d82bd8ae8795f7c8da916.zip cpython-ded1c4df0b98b05af22d82bd8ae8795f7c8da916.tar.gz cpython-ded1c4df0b98b05af22d82bd8ae8795f7c8da916.tar.bz2 |
Testcase for patch #1484695.
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r-- | Lib/tarfile.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 00789f3..ccbfdde 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -145,7 +145,10 @@ def nti(s): # There are two possible encodings for a number field, see # itn() below. if s[0] != chr(0200): - n = int(s.rstrip(NUL + " ") or "0", 8) + try: + n = int(s.rstrip(NUL + " ") or "0", 8) + except ValueError: + raise HeaderError("invalid header") else: n = 0L for i in xrange(len(s) - 1): @@ -826,11 +829,7 @@ class TarInfo(object): if buf.count(NUL) == BLOCKSIZE: raise HeaderError("empty header") - try: - chksum = nti(buf[148:156]) - except ValueError: - raise HeaderError("invalid header") - + chksum = nti(buf[148:156]) if chksum not in calc_chksums(buf): raise HeaderError("bad checksum") |