This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author neologix
Recipients eric.araujo, matejcik, neologix, pitrou, rosslagerwall, santoso.wijaya, vstinner
Date 2012-02-25.13:08:13
SpamBayes Score 2.7755576e-16
Marked as misclassified No
Message-id <CAH_1eM33cvpaWUJzhGMfAm09-gsoJX5pq+WcZN650iM_SjkZ9Q@mail.gmail.com>
In-reply-to <1329868289.43.0.901396663923.issue12801@psf.upfronthosting.co.za>
Content
>  - 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'
History
Date User Action Args
2012-02-25 13:08:14neologixsetrecipients: + neologix, pitrou, vstinner, matejcik, eric.araujo, santoso.wijaya, rosslagerwall
2012-02-25 13:08:13neologixlinkissue12801 messages
2012-02-25 13:08:13neologixcreate