summaryrefslogtreecommitdiffstats
path: root/cmd.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2012-04-23 22:43:09 +0000
committerNicholas Marriott <nicm@openbsd.org>2012-04-23 22:43:09 +0000
commit0f9e0d1cfe645f276ef471131b55e9bfe2276758 (patch)
tree8e0d75e4e4d37fa967cec49858caf134fdc163c4 /cmd.c
parent48e6ebbe1ec8bb2631bbe5afe7c67ea0198d43d4 (diff)
Do not return a buffer on the stack, mentioned by jsg a while ago.
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/cmd.c b/cmd.c
index 5d8e7209..a3a70284 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1325,8 +1325,10 @@ find_home:
return (s->cwd);
complete_path:
- if (root[skip] == '\0')
- return (root);
+ if (root[skip] == '\0') {
+ strlcpy(path, root, sizeof path);
+ return (path);
+ }
n = snprintf(path, sizeof path, "%s/%s", root, cwd + skip);
if (n > 0 && (size_t)n < sizeof path)
return (path);