summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2016-09-23 18:24:28 (GMT)
committerChristian Heimes <christian@python.org>2016-09-23 18:24:28 (GMT)
commit3cb091e576cf3c8a71b8cff6951cfadfd8f5cd7a (patch)
tree666a1ab3a1a0ca1808dbfee407683917842b8e14 /Modules
parent2f366cab48ef60d947949f15983dd660f1a14462 (diff)
downloadcpython-3cb091e576cf3c8a71b8cff6951cfadfd8f5cd7a.zip
cpython-3cb091e576cf3c8a71b8cff6951cfadfd8f5cd7a.tar.gz
cpython-3cb091e576cf3c8a71b8cff6951cfadfd8f5cd7a.tar.bz2
Increase buffer for readlink() in case OS will support longer names one day.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index c993fb6..d737624 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7087,7 +7087,7 @@ posix_readlink(PyObject *self, PyObject *args, PyObject *kwargs)
{
path_t path;
int dir_fd = DEFAULT_DIR_FD;
- char buffer[MAXPATHLEN];
+ char buffer[MAXPATHLEN+1];
ssize_t length;
PyObject *return_value = NULL;
static char *keywords[] = {"path", "dir_fd", NULL};
@@ -7102,16 +7102,17 @@ posix_readlink(PyObject *self, PyObject *args, PyObject *kwargs)
Py_BEGIN_ALLOW_THREADS
#ifdef HAVE_READLINKAT
if (dir_fd != DEFAULT_DIR_FD)
- length = readlinkat(dir_fd, path.narrow, buffer, sizeof(buffer));
+ length = readlinkat(dir_fd, path.narrow, buffer, MAXPATHLEN);
else
#endif
- length = readlink(path.narrow, buffer, sizeof(buffer));
+ length = readlink(path.narrow, buffer, MAXPATHLEN);
Py_END_ALLOW_THREADS
if (length < 0) {
return_value = path_error(&path);
goto exit;
}
+ buffer[length] = '\0';
if (PyUnicode_Check(path.object))
return_value = PyUnicode_DecodeFSDefaultAndSize(buffer, length);