hirokazu.yamamoto
2008-09-09 13:56:11 UTC
Author: hirokazu.yamamoto
Date: Tue Sep 9 15:56:11 2008
New Revision: 66338
Log:
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.
Modified:
python/branches/py3k/Modules/getpath.c
Modified: python/branches/py3k/Modules/getpath.c
==============================================================================
--- python/branches/py3k/Modules/getpath.c (original)
+++ python/branches/py3k/Modules/getpath.c Tue Sep 9 15:56:11 2008
@@ -183,6 +183,7 @@
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 @@
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 */
Date: Tue Sep 9 15:56:11 2008
New Revision: 66338
Log:
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.
Modified:
python/branches/py3k/Modules/getpath.c
Modified: python/branches/py3k/Modules/getpath.c
==============================================================================
--- python/branches/py3k/Modules/getpath.c (original)
+++ python/branches/py3k/Modules/getpath.c Tue Sep 9 15:56:11 2008
@@ -183,6 +183,7 @@
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 @@
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 */