summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Adams <joeyadams3.14159@gmail.com>2011-02-24 23:24:36 -0500
committerRusty Russell <rusty@rustcorp.com.au>2011-03-08 10:53:47 +1030
commit5079b95c1121e7a8e5b0b18b094ec7d8a539c7c7 (patch)
tree251dde6ca496adb0ab11a8b60e78a588baf14ed6
parentc67c37e8d251b77cd6827ebfaae6f298f1a7b81a (diff)
tools: Fixed unchecked *strrchr in a couple places.
tools/ccan_depends --compile ccan/module (without a trailing slash) results in a segfault.
-rw-r--r--tools/ccanlint/compulsory_tests/depends_exist.c3
-rw-r--r--tools/depends.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/tools/ccanlint/compulsory_tests/depends_exist.c b/tools/ccanlint/compulsory_tests/depends_exist.c
index 12eaf021..b6be1f94 100644
--- a/tools/ccanlint/compulsory_tests/depends_exist.c
+++ b/tools/ccanlint/compulsory_tests/depends_exist.c
@@ -41,7 +41,8 @@ static void check_depends_exist(struct manifest *m,
char **deps;
char *updir = talloc_strdup(m, m->dir);
- *strrchr(updir, '/') = '\0';
+ if (strrchr(updir, '/'))
+ *strrchr(updir, '/') = '\0';
if (safe_mode)
deps = get_safe_ccan_deps(m, m->dir, true,
diff --git a/tools/depends.c b/tools/depends.c
index 870f1e49..82524da0 100644
--- a/tools/depends.c
+++ b/tools/depends.c
@@ -59,7 +59,8 @@ static char *compile_info(const void *ctx, const char *dir)
return NULL;
ccandir = talloc_dirname(ctx, dir);
- *strrchr(ccandir, '/') = '\0';
+ if (strrchr(ccandir, '/'))
+ *strrchr(ccandir, '/') = '\0';
compiled = maybe_temp_file(ctx, "", false, "info");
if (compile_and_link(ctx, info_c_file, ccandir, "",