]> git.sesse.net Git - vlc/commitdiff
posix: use getcwd() directly, ignore $PWD and avoid ToCToU
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 14 Sep 2014 14:47:32 +0000 (17:47 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 14 Sep 2014 14:47:32 +0000 (17:47 +0300)
src/posix/filesystem.c

index e26d3cda2b7e3e2bc4261727b9e4c795945c09bf..45df501fc80837b984bcb9a63579b19934d8eefa 100644 (file)
@@ -211,18 +211,6 @@ int vlc_rename (const char *oldpath, const char *newpath)
  */
 char *vlc_getcwd (void)
 {
-    /* Try $PWD */
-    const char *pwd = getenv ("PWD");
-    if (pwd != NULL)
-    {
-        struct stat s1, s2;
-        /* Make sure $PWD is correct */
-        if (stat (pwd, &s1) == 0 && stat (".", &s2) == 0
-         && s1.st_dev == s2.st_dev && s1.st_ino == s2.st_ino)
-            return strdup (pwd);
-    }
-
-    /* Otherwise iterate getcwd() until the buffer is big enough */
     long path_max = pathconf (".", _PC_PATH_MAX);
     size_t size = (path_max == -1 || path_max > 4096) ? 4096 : path_max;