summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-12-20 11:55:16 (GMT)
committerGeorg Brandl <georg@python.org>2006-12-20 11:55:16 (GMT)
commitded1c4df0b98b05af22d82bd8ae8795f7c8da916 (patch)
tree279ed70caa94a6e534ac1318b024ed73a06a5656 /Lib/tarfile.py
parent94547f7646895e032f8fc145529d9efc3a70760d (diff)
downloadcpython-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.py11
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")