Date: Wed, 28 Jun 2017 04:24:10 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r320433 - head/libexec/rshd Message-ID: <201706280424.v5S4OAE3097144@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706280424.v5S4OAE3097144>