From a01b8280507b8c0c07572661365dbb023854f437 Mon Sep 17 00:00:00 2001 From: aszlig Date: Thu, 30 Nov 2017 13:16:56 +0100 Subject: 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 --- pkgs/build-support/build-sandbox/src/setup.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'pkgs/build-support/build-sandbox') 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; -- cgit 1.4.1