]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - mount/realpath.c
Imported from util-linux-2.7.1 tarball.
[thirdparty/util-linux.git] / mount / realpath.c
index 4ea46a3116f0def68eba5cd04e2e6c73caa04ef9..4214cad7293419e1a3b77751342330fd97c50cf8 100644 (file)
  * GNU Library Public License for more details.
  */
 
+#define HAVE_GETCWD
+
 /*
- * realpath.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp
+ * This routine is part of libc.  We include it nevertheless,
+ * since the libc version has some security flaws.
  */
 
 #ifdef __linux__
@@ -79,9 +82,14 @@ char *resolved_path;
        int n;
 
        /* Make a copy of the source path since we may need to modify it. */
+       if (strlen(path) >= PATH_MAX) {
+               errno = ENAMETOOLONG;
+               return NULL;
+       }
        strcpy(copy_path, path);
        path = copy_path;
        max_path = copy_path + PATH_MAX - 2;
+
        /* If it's a relative pathname use getwd for starters. */
        if (*path != '/') {
 #ifdef HAVE_GETCWD