From 805a2c95ad57871f814dc4e4fe566f6e3bfe7ef1 Mon Sep 17 00:00:00 2001 From: delphij 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;