]> granicus.if.org Git - python/commitdiff
Merged revisions 81665 via svnmerge from
authorLars Gustäbel <lars@gustaebel.de>
Thu, 3 Jun 2010 10:15:18 +0000 (10:15 +0000)
committerLars Gustäbel <lars@gustaebel.de>
Thu, 3 Jun 2010 10:15:18 +0000 (10:15 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r81665 | lars.gustaebel | 2010-06-03 12:11:52 +0200 (Thu, 03 Jun 2010) | 11 lines

  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.
  ........
................

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

index 125d95dd8a8a89f1bdf90220daee930679ecf68c..bc608e9d79072016b22799b0b008c1871002474d 100644 (file)
@@ -1857,7 +1857,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
index 1a556eb0f59ced1982bc52e1a3cfafecea27f324..124f0e97f8455ac66c7f1d78ac18f0383a9619f2 100644 (file)
@@ -616,10 +616,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:
index ea7e5034a03b518845b584728a8fc5bfb5356925..91d59b18280f1d0e36731b36b21774baffa97d8a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -54,6 +54,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.