about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2017-11-30 13:16:56 +0100
committeraszlig <aszlig@nix.build>2017-11-30 13:22:11 +0100
commita01b8280507b8c0c07572661365dbb023854f437 (patch)
treed2e5ac49daad5dee26d38ca4def7b1189afaebc1 /pkgs/build-support
parent2df7436fb32cf7ac871b1143a8270f8cfa16b7e1 (diff)
pkgs/sandbox: Check for absolute path in makedirs
Though we're already checking the realpath() let's actually make sure
that the path begins with a slash, otherwise we'll run into a segfault
later when we try to access the second byte of path.

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/build-sandbox/src/setup.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/pkgs/build-support/build-sandbox/src/setup.c b/pkgs/build-support/build-sandbox/src/setup.c
index dfe550e0..a23983c8 100644
--- a/pkgs/build-support/build-sandbox/src/setup.c
+++ b/pkgs/build-support/build-sandbox/src/setup.c
@@ -95,6 +95,11 @@ static bool makedirs(const char *path, bool do_cache)
 {
     char *tmp, *segment;
 
+    if (*path != '/') {
+        fprintf(stderr, "fatal: Path '%s' is not absolute.\n", path);
+        return false;
+    }
+
     if ((tmp = strdup(path)) == NULL) {
         fprintf(stderr, "strdup of %s: %s\n", path, strerror(errno));
         return false;