summaryrefslogtreecommitdiffstats
path: root/mount/realpath.c
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:34 +0100
committerKarel Zak2006-12-07 00:25:34 +0100
commitfd6b7a7ffc50400704beb41d5a23af5f9edb1eed (patch)
tree997c0ca2abc018369babd7da59bcd0afe492068e /mount/realpath.c
parentImported from util-linux-2.5 tarball. (diff)
downloadkernel-qcow2-util-linux-fd6b7a7ffc50400704beb41d5a23af5f9edb1eed.tar.gz
kernel-qcow2-util-linux-fd6b7a7ffc50400704beb41d5a23af5f9edb1eed.tar.xz
kernel-qcow2-util-linux-fd6b7a7ffc50400704beb41d5a23af5f9edb1eed.zip
Imported from util-linux-2.7.1 tarball.
Diffstat (limited to 'mount/realpath.c')
-rw-r--r--mount/realpath.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/mount/realpath.c b/mount/realpath.c
index 4ea46a311..4214cad72 100644
--- a/mount/realpath.c
+++ b/mount/realpath.c
@@ -13,8 +13,11 @@
* 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