Do not return a buffer on the stack, mentioned by jsg a while ago.

This commit is contained in:
Nicholas Marriott 2012-04-23 22:43:09 +00:00
parent 48e6ebbe1e
commit 0f9e0d1cfe
1 changed files with 4 additions and 2 deletions

6
cmd.c
View File

@ -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);