python / cpython

The Python programming language
https://www.python.org/
Other
60.06k stars 29.09k forks source link

`posixpath.realpath(..., strict=True)` doesn't limit symlinks #118441

Open nineteendo opened 3 weeks ago

nineteendo commented 3 weeks ago

Bug report

Bug description:

>>> import posixpath
>>> posixpath.realpath("s/" * 33, strict=True)
'/Users/wannes/path-picker/link-test/dirs'

Expected OSError(errno.ELOOP, "Too many symbolic links", path) matching realpath on macOS:

wannes@Stefans-iMac dirs % realpath s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s
realpath: s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s: Too many levels of symbolic links

CPython versions tested on:

3.12

Operating systems tested on:

macOS

Linked PRs