]> granicus.if.org Git - python/commitdiff
bpo-38353: Fix calculate_argv0_path() for symlinks (GH-16549)
authorVictor Stinner <vstinner@python.org>
Thu, 3 Oct 2019 21:17:00 +0000 (23:17 +0200)
committerGitHub <noreply@github.com>
Thu, 3 Oct 2019 21:17:00 +0000 (23:17 +0200)
calculate_argv0_path() must read argv0_path link, not read
program_full_path link.

Modules/getpath.c

index 4246d4ca5ac0d52e46a63f7d18974a30495312e6..fca87c7b0ee93f672c25f3a8f819ae58b24b6e57 100644 (file)
@@ -959,7 +959,7 @@ calculate_argv0_path(PyCalculatePath *calculate, const wchar_t *program_full_pat
 #if HAVE_READLINK
     wchar_t tmpbuffer[MAXPATHLEN + 1];
     const size_t buflen = Py_ARRAY_LENGTH(tmpbuffer);
-    int linklen = _Py_wreadlink(program_full_path, tmpbuffer, buflen);
+    int linklen = _Py_wreadlink(argv0_path, tmpbuffer, buflen);
     while (linklen != -1) {
         if (_Py_isabs(tmpbuffer)) {
             /* tmpbuffer should never be longer than MAXPATHLEN,