]> granicus.if.org Git - python/commitdiff
Merged revisions 81663 via svnmerge from
authorLars Gustäbel <lars@gustaebel.de>
Thu, 3 Jun 2010 10:07:08 +0000 (10:07 +0000)
committerLars Gustäbel <lars@gustaebel.de>
Thu, 3 Jun 2010 10:07:08 +0000 (10:07 +0000)
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.
........

Lib/tarfile.py
Lib/test/test_tarfile.py
Misc/NEWS

index 8c2d26b2e46eddd0513987fab1ab2fdc63b46d40..98ae12f4c01beeb512eabd8a6e7e5da633fbc147 100644 (file)
@@ -1880,7 +1880,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 = 0L
index 786f57a9149e2dfb27576960c353689f6df8557f..909b08cece87098a46f7133c1f21e3a9c59bed97 100644 (file)
@@ -617,10 +617,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("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:
index 70e3ceeee42deb00dc3b377cf94b98081fffa8c5..e4a848edab87c9156e86be2647a4eed0f3b9ceee 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -58,6 +58,9 @@ C-API
 Library
 -------
 
+- Issue #8833: tarfile created hard link entries with a size field != 0 by
+  mistake.
+
 - Issue #1368247: set_charset (and therefore MIMEText) now automatically
   encodes a unicode _payload to the output_charset.