diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/path-util.c | 9 | ||||
-rw-r--r-- | src/test/test-path-util.c | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/shared/path-util.c b/src/shared/path-util.c index 1ad1084b2d..e35d7f8d67 100644 --- a/src/shared/path-util.c +++ b/src/shared/path-util.c @@ -427,15 +427,16 @@ int find_binary(const char *name, char **filename) { assert(name); if (strchr(name, '/')) { + if (access(name, X_OK) < 0) + return -errno; + if (filename) { char *p; - if (path_is_absolute(name)) - p = strdup(name); - else - p = path_make_absolute_cwd(name); + p = path_make_absolute_cwd(name); if (!p) return -ENOMEM; + *filename = p; } diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index a2cf0af75f..527b275656 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -104,6 +104,8 @@ static void test_find_binary(void) { free(p); assert(find_binary("xxxx-xxxx", &p) == -ENOENT); + + assert(find_binary("/some/dir/xxxx-xxxx", &p) == -ENOENT); } static void test_prefixes(void) { |