mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.9] gh-135034: Normalize link targets in tarfile, add os.path.realpath(strict='allow_missing')
(GH-135037) (GH-135084)
Addresses CVEs 2024-12718, 2025-4138, 2025-4330, and 2025-4517.
(cherry picked from commit 3612d8f517
)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Seth Michael Larson <seth@python.org>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
24eaf53bc6
commit
dd8f187d07
11 changed files with 949 additions and 137 deletions
|
@ -8,7 +8,7 @@ import stat
|
|||
|
||||
__all__ = ['commonprefix', 'exists', 'getatime', 'getctime', 'getmtime',
|
||||
'getsize', 'isdir', 'isfile', 'samefile', 'sameopenfile',
|
||||
'samestat']
|
||||
'samestat', 'ALLOW_MISSING']
|
||||
|
||||
|
||||
# Does a path exist?
|
||||
|
@ -153,3 +153,12 @@ def _check_arg_types(funcname, *args):
|
|||
f'os.PathLike object, not {s.__class__.__name__!r}') from None
|
||||
if hasstr and hasbytes:
|
||||
raise TypeError("Can't mix strings and bytes in path components") from None
|
||||
|
||||
# A singleton with a true boolean value.
|
||||
@object.__new__
|
||||
class ALLOW_MISSING:
|
||||
"""Special value for use in realpath()."""
|
||||
def __repr__(self):
|
||||
return 'os.path.ALLOW_MISSING'
|
||||
def __reduce__(self):
|
||||
return self.__class__.__name__
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue