summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2008-09-09 13:56:11 (GMT)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2008-09-09 13:56:11 (GMT)
commitf8247796b12ba699da67601f7ff5f043b2d7998e (patch)
tree70ef487cd219d5bc930a8127a82ac0f5aec25964 /Modules
parent29d95eb6f2119888e7c30ce185e6ae1941e70e57 (diff)
downloadcpython-f8247796b12ba699da67601f7ff5f043b2d7998e.zip
cpython-f8247796b12ba699da67601f7ff5f043b2d7998e.tar.gz
cpython-f8247796b12ba699da67601f7ff5f043b2d7998e.tar.bz2
Issue #3813: cannot lanch python.exe via symbolic link on cygwin.
readlink(2) can return non-null-terminated string. Reviewed by Amaury Forgeot d'Arc.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/getpath.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c
index f752a7f..064877c 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -183,6 +183,7 @@ _Py_wreadlink(const wchar_t *path, wchar_t *buf, size_t bufsiz)
errno = EINVAL;
return -1;
}
+ cbuf[res] = '\0'; /* buf will be null terminated */
r1 = mbstowcs(buf, cbuf, bufsiz);
if (r1 == -1) {
errno = EINVAL;
@@ -559,8 +560,6 @@ calculate_path(void)
wchar_t tmpbuffer[MAXPATHLEN+1];
int linklen = _Py_wreadlink(progpath, tmpbuffer, MAXPATHLEN);
while (linklen != -1) {
- /* It's not null terminated! */
- tmpbuffer[linklen] = '\0';
if (tmpbuffer[0] == SEP)
/* tmpbuffer should never be longer than MAXPATHLEN,
but extra check does not hurt */