summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2020-10-28 06:59:36 -0700
committerAndrew G. Morgan <morgan@kernel.org>2020-10-28 06:59:36 -0700
commit9d8eaab7f74cf1d925910901e5181173ab11d14d (patch)
tree18998ef4139a09f31c4cbd8409eaaa335ca9017b
parent24375fb114e6a78aa3ca6907399b8601d1db6f36 (diff)
downloadlibcap2-9d8eaab7f74cf1d925910901e5181173ab11d14d.tar.gz
Guarantee sufficient memory for scratch pathname
Fix a malloc bug with single entry/short PATHs in capsh code for "==" support. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r--progs/capsh.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/progs/capsh.c b/progs/capsh.c
index 4f0b603..899f79c 100644
--- a/progs/capsh.c
+++ b/progs/capsh.c
@@ -350,7 +350,7 @@ static char *find_self(const char *arg0)
}
parts = strdup(path);
- scratch = malloc(1+strlen(path));
+ scratch = malloc(2+strlen(path)+strlen(arg0));
if (parts == NULL || scratch == NULL) {
fprintf(stderr, "insufficient memory for path building\n");
exit(1);