summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-03-27 15:38:01 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-03-27 15:38:01 -0400
commitcd929976f8beb208c0c3524ae11de6ceed941324 (patch)
tree43aed94089ac02b122249e546a1bdeda7221c6b2
parent943581a4d59b42a684666f146324d908b0dac428 (diff)
downloadbfs-cd929976f8beb208c0c3524ae11de6ceed941324.tar.xz
xspawn: Fix bfs_resolve_late() error reporting
-rw-r--r--src/xspawn.c10
-rw-r--r--tests/xspawn.c23
2 files changed, 25 insertions, 8 deletions
diff --git a/src/xspawn.c b/src/xspawn.c
index f67adec..065fbae 100644
--- a/src/xspawn.c
+++ b/src/xspawn.c
@@ -364,16 +364,10 @@ static int bfs_resolve_late(struct bfs_resolver *res) {
res->done = true;
return 0;
}
-
- if (end) {
- path = end + 1;
- } else {
- errno = ENOENT;
- return -1;
- }
}
- return 0;
+ errno = ENOENT;
+ return -1;
}
/** Check if we can skip path resolution entirely. */
diff --git a/tests/xspawn.c b/tests/xspawn.c
index 5f80e76..c1bac36 100644
--- a/tests/xspawn.c
+++ b/tests/xspawn.c
@@ -170,6 +170,27 @@ out:
return ret;
}
+static bool check_resolve(void) {
+ bool ret = true;
+ char *exe;
+
+ exe = bfs_spawn_resolve("sh");
+ ret &= bfs_pcheck(exe, "bfs_spawn_resolve('sh')");
+ free(exe);
+
+ exe = bfs_spawn_resolve("/bin/sh");
+ ret &= bfs_pcheck(exe && strcmp(exe, "/bin/sh") == 0);
+ free(exe);
+
+ exe = bfs_spawn_resolve("bin/tests/xspawnee");
+ ret &= bfs_pcheck(exe && strcmp(exe, "bin/tests/xspawnee") == 0);
+ free(exe);
+
+ ret &= bfs_pcheck(!bfs_spawn_resolve("eW6f5RM9Qi") && errno == ENOENT);
+
+ return ret;
+}
+
bool check_xspawn(void) {
bool ret = true;
@@ -179,5 +200,7 @@ bool check_xspawn(void) {
ret &= check_enoent(true);
ret &= check_enoent(false);
+ ret &= check_resolve();
+
return ret;
}