diff options
author | aszlig <aszlig@nix.build> | 2017-11-30 13:16:56 +0100 |
---|---|---|
committer | aszlig <aszlig@nix.build> | 2017-11-30 13:22:11 +0100 |
commit | a01b8280507b8c0c07572661365dbb023854f437 (patch) | |
tree | d2e5ac49daad5dee26d38ca4def7b1189afaebc1 | |
parent | 2df7436fb32cf7ac871b1143a8270f8cfa16b7e1 (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>
-rw-r--r-- | pkgs/build-support/build-sandbox/src/setup.c | 5 |
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; |