diff options
author | delphij <delphij@FreeBSD.org> | 2017-07-17 06:37:46 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2017-07-17 06:37:46 +0000 |
commit | ee5e5e753c9f700f65dd5f6c7fd72019cffdfe61 (patch) | |
tree | dda78a2dd6d0542e3afde7eb931bee5baa1de2ec | |
parent | cb9c6059b4d3cfa58d8c5c0da642c9f0e4271c62 (diff) | |
download | FreeBSD-src-ee5e5e753c9f700f65dd5f6c7fd72019cffdfe61.zip FreeBSD-src-ee5e5e753c9f700f65dd5f6c7fd72019cffdfe61.tar.gz |
MFC r320433:
Use strlcpy() instead of strncpy() and nul-terminating.
-rw-r--r-- | libexec/rshd/rshd.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/libexec/rshd/rshd.c b/libexec/rshd/rshd.c index 7cdacae..c84c154 100644 --- a/libexec/rshd/rshd.c +++ b/libexec/rshd/rshd.c @@ -322,8 +322,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); @@ -364,9 +363,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, |