Date: Mon, 17 Jul 2017 06:36:42 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r321068 - stable/11/libexec/rshd Message-ID: <201707170636.v6H6agP9093402@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Mon Jul 17 06:36:42 2017 New Revision: 321068 URL: https://svnweb.freebsd.org/changeset/base/321068 Log: MFC r320433: Use strlcpy() instead of strncpy() and nul-terminating. Modified: stable/11/libexec/rshd/rshd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/libexec/rshd/rshd.c ============================================================================== --- stable/11/libexec/rshd/rshd.c Mon Jul 17 06:28:34 2017 (r321067) +++ stable/11/libexec/rshd/rshd.c Mon Jul 17 06:36:42 2017 (r321068) @@ -338,8 +338,7 @@ doit(struct sockaddr *fromp) pam_err = pam_authenticate(pamh, 0); if (pam_err == PAM_SUCCESS) { if ((pam_err = pam_get_user(pamh, &cp, NULL)) == PAM_SUCCESS) { - strncpy(luser, cp, sizeof(luser)); - luser[sizeof(luser) - 1] = '\0'; + strlcpy(luser, cp, sizeof(luser)); /* XXX truncation! */ } pam_err = pam_acct_mgmt(pamh, 0); @@ -386,9 +385,7 @@ doit(struct sockaddr *fromp) if (lc != NULL && fromp->sa_family == AF_INET) { /*XXX*/ char remote_ip[MAXHOSTNAMELEN]; - strncpy(remote_ip, numericname, - sizeof(remote_ip) - 1); - remote_ip[sizeof(remote_ip) - 1] = 0; + strlcpy(remote_ip, numericname, sizeof(remote_ip)); /* XXX truncation! */ if (!auth_hostok(lc, rhost, remote_ip)) { syslog(LOG_INFO|LOG_AUTH,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707170636.v6H6agP9093402>