Commit 2ee9c6fa authored by Lars Gustäbel's avatar Lars Gustäbel

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.
parent 593e4ca7
...@@ -1884,7 +1884,7 @@ class TarFile(object): ...@@ -1884,7 +1884,7 @@ class TarFile(object):
tarinfo.mode = stmd tarinfo.mode = stmd
tarinfo.uid = statres.st_uid tarinfo.uid = statres.st_uid
tarinfo.gid = statres.st_gid tarinfo.gid = statres.st_gid
if stat.S_ISREG(stmd): if type == REGTYPE:
tarinfo.size = statres.st_size tarinfo.size = statres.st_size
else: else:
tarinfo.size = 0L tarinfo.size = 0L
......
...@@ -662,10 +662,14 @@ class WriteTest(WriteTestBase): ...@@ -662,10 +662,14 @@ class WriteTest(WriteTestBase):
if hasattr(os, "link"): if hasattr(os, "link"):
link = os.path.join(TEMPDIR, "link") link = os.path.join(TEMPDIR, "link")
target = os.path.join(TEMPDIR, "link_target") target = os.path.join(TEMPDIR, "link_target")
open(target, "wb").close() fobj = open(target, "wb")
fobj.write("aaa")
fobj.close()
os.link(target, link) os.link(target, link)
try: try:
tar = tarfile.open(tmpname, self.mode) tar = tarfile.open(tmpname, self.mode)
# Record the link target in the inodes list.
tar.gettarinfo(target)
tarinfo = tar.gettarinfo(link) tarinfo = tar.gettarinfo(link)
self.assertEqual(tarinfo.size, 0) self.assertEqual(tarinfo.size, 0)
finally: finally:
......
...@@ -46,6 +46,9 @@ C-API ...@@ -46,6 +46,9 @@ C-API
Library Library
------- -------
- Issue #8833: tarfile created hard link entries with a size field != 0 by
mistake.
- Issue #1368247: set_charset (and therefore MIMEText) now automatically - Issue #1368247: set_charset (and therefore MIMEText) now automatically
encodes a unicode _payload to the output_charset. encodes a unicode _payload to the output_charset.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment