Message154247
> - os.realpath() uses canonicalize_file_name() if available, or use realpath() with a buffer of MAXPATHLEN bytes
MAXPATHLEN is not necessarily defined (e.g. on the Hurd): if it's not
defined, it is set either to MAX_PATH (if it's defined an greater than
1024), or arbitrarily to 1024.
Thus, we can't pass it to realpath(3), since we don't know for sure
that realpath(3) won't return a string greater than MAXPATHLEN, which
could result in a buffer overflow.
Also, there's the problem that realpath(3) returns ENOENT, whereas
os.path.realpath() doesn't:
without patch:
$ python -c "import os; os.path.realpath('/nosuchfile')"
with patch:
$ ./python -c "import os; os.path.realpath('/nosuchfile')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/cf/python/cpython/Lib/posixpath.py", line 385, in realpath
return os.realpath(filename)
FileNotFoundError: [Errno 2] No such file or directory: '/nosuchfile' |
|
Date |
User |
Action |
Args |
2012-02-25 13:08:14 | neologix | set | recipients:
+ neologix, pitrou, vstinner, matejcik, eric.araujo, santoso.wijaya, rosslagerwall |
2012-02-25 13:08:13 | neologix | link | issue12801 messages |
2012-02-25 13:08:13 | neologix | create | |
|