Charles-François Natali <neolo...@free.fr> added the comment:

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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12801>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to