svn commit: r320433 - head/libexec/rshd
Xin LI
delphij at FreeBSD.org
Wed Jun 28 04:24:11 UTC 2017
Author: delphij
Date: Wed Jun 28 04:24:10 2017
New Revision: 320433
URL: https://svnweb.freebsd.org/changeset/base/320433
Log:
Use strlcpy() instead of strncpy() and nul-terminating.
MFC after: 2 weeks
Modified:
head/libexec/rshd/rshd.c
Modified: head/libexec/rshd/rshd.c
==============================================================================
--- head/libexec/rshd/rshd.c Wed Jun 28 04:23:20 2017 (r320432)
+++ head/libexec/rshd/rshd.c Wed Jun 28 04:24:10 2017 (r320433)
@@ -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,
More information about the svn-src-all
mailing list