Skip to content

Commit 2e68342

Browse files
committed
Fix also test_realpath_limit_attack()
Fix test_realpath_limit_attack(): the test fails with ELOOP on Cygwin.
1 parent 8cb7011 commit 2e68342

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Lib/test/test_tarfile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3949,7 +3949,7 @@ def test_realpath_limit_attack(self):
39493949
# path fits in PATH_MAX, but it overflows when the final symlink
39503950
# is expanded
39513951
steps = "abcdefghijklmnop"
3952-
if sys.platform == 'win32':
3952+
if sys.platform in ('win32', 'cygwin'):
39533953
component = 'd' * 25
39543954
elif 'PC_PATH_MAX' in os.pathconf_names:
39553955
max_path_len = os.pathconf(self.outerdir.parent, "PC_PATH_MAX")
@@ -3989,6 +3989,9 @@ def test_realpath_limit_attack(self):
39893989
check_flag=False)):
39903990
if sys.platform == 'win32':
39913991
self.expect_exception((FileNotFoundError, FileExistsError))
3992+
elif sys.platform == 'cygwin':
3993+
exc = self.expect_exception(OSError)
3994+
self.assertEqual(exc.errno, errno.ELOOP)
39923995
elif self.raised_exception:
39933996
# Cannot symlink/hardlink: tarfile falls back to getmember()
39943997
self.expect_exception(KeyError)
@@ -4010,7 +4013,8 @@ def test_realpath_limit_attack(self):
40104013
# 206: ERROR_FILENAME_EXCED_RANGE
40114014
self.assertIn(exc.winerror, (3, 5, 206))
40124015
else:
4013-
self.assertEqual(exc.errno, errno.ENAMETOOLONG)
4016+
self.assertIn(exc.errno,
4017+
(errno.ENAMETOOLONG, errno.ELOOP))
40144018

40154019
@symlink_test
40164020
def test_parent_symlink2(self):

0 commit comments

Comments
 (0)