From 995c9a50ab7e68eba9d47fd8fd30313046330f21 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Tue, 24 Apr 2012 16:22:28 +0000 Subject: [PATCH] Sync OpenBSD patchset 1099: Do not return a buffer on the stack, mentioned by jsg a while ago. --- cmd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd.c b/cmd.c index f231b230..7aefeffd 100644 --- a/cmd.c +++ b/cmd.c @@ -1324,8 +1324,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);