[vlc-commits] posix: use getcwd() directly, ignore $PWD and avoid ToCToU

Rémi Denis-Courmont git at videolan.org
Sun Sep 14 16:47:56 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Sep 14 17:47:32 2014 +0300| [74c4dd3966a673640b87c3ca98ea194193bead42] | committer: Rémi Denis-Courmont

posix: use getcwd() directly, ignore $PWD and avoid ToCToU

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=74c4dd3966a673640b87c3ca98ea194193bead42
---

 src/posix/filesystem.c |   12 ------------
 1 file changed, 12 deletions(-)

diff --git a/src/posix/filesystem.c b/src/posix/filesystem.c
index e26d3cd..45df501 100644
--- a/src/posix/filesystem.c
+++ b/src/posix/filesystem.c
@@ -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;
 



More information about the vlc-commits mailing list