From aff7b6c709179f9a827ddd01c15e6e227bb7fe08 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Tue, 5 Dec 2017 07:11:56 +0000 Subject: [PATCH] Use strlcpy(). MFC after: 2 weeks --- usr.bin/su/su.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c index 45c30d362082..65c5640b0bae 100644 --- a/usr.bin/su/su.c +++ b/usr.bin/su/su.c @@ -277,9 +277,9 @@ main(int argc, char *argv[]) if (asme) { if (pwd->pw_shell != NULL && *pwd->pw_shell != '\0') { /* must copy - pwd memory is recycled */ - shell = strncpy(shellbuf, pwd->pw_shell, + strlcpy(shellbuf, pwd->pw_shell, sizeof(shellbuf)); - shellbuf[sizeof(shellbuf) - 1] = '\0'; + shell = shellbuf; } else { shell = _PATH_BSHELL;