summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Gustäbel <lars@gustaebel.de>2010-06-03 10:11:52 (GMT)
committerLars Gustäbel <lars@gustaebel.de>2010-06-03 10:11:52 (GMT)
commit2470ff19e620e96a39c58a2827646205024db800 (patch)
treee1898ac8c79f5e7c3144b0e3019ebf64dfb84def
parent850fc85e69b31095769bdb40b3df04e70848eddd (diff)
downloadcpython-2470ff19e620e96a39c58a2827646205024db800.zip
cpython-2470ff19e620e96a39c58a2827646205024db800.tar.gz
cpython-2470ff19e620e96a39c58a2827646205024db800.tar.bz2
Merged revisions 81663 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81663 | lars.gustaebel | 2010-06-03 11:56:22 +0200 (Thu, 03 Jun 2010) | 4 lines Issue #8833: tarfile created hard link entries with a size field != 0 by mistake. The associated testcase did not expose this bug because it was broken too. ........
-rw-r--r--Lib/tarfile.py2
-rw-r--r--Lib/test/test_tarfile.py6
-rw-r--r--Misc/NEWS3
3 files changed, 9 insertions, 2 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index e9480c8..8559e96 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1920,7 +1920,7 @@ class TarFile(object):
tarinfo.mode = stmd
tarinfo.uid = statres.st_uid
tarinfo.gid = statres.st_gid
- if stat.S_ISREG(stmd):
+ if type == REGTYPE:
tarinfo.size = statres.st_size
else:
tarinfo.size = 0
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index c0741ee..ec6f82f 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -661,10 +661,14 @@ class WriteTest(WriteTestBase):
if hasattr(os, "link"):
link = os.path.join(TEMPDIR, "link")
target = os.path.join(TEMPDIR, "link_target")
- open(target, "wb").close()
+ fobj = open(target, "wb")
+ fobj.write(b"aaa")
+ fobj.close()
os.link(target, link)
try:
tar = tarfile.open(tmpname, self.mode)
+ # Record the link target in the inodes list.
+ tar.gettarinfo(target)
tarinfo = tar.gettarinfo(link)
self.assertEqual(tarinfo.size, 0)
finally:
diff --git a/Misc/NEWS b/Misc/NEWS
index 4c60de3..9195a04 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -398,6 +398,9 @@ C-API
Library
-------
+- Issue #8833: tarfile created hard link entries with a size field != 0 by
+ mistake.
+
- Charset.body_encode now correctly handles base64 encoding by encoding
with the output_charset before calling base64mime.encode. Passes the
tests from 2.x issue 1368247.