summaryrefslogtreecommitdiff
path: root/usr.sbin/ypbind
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2024-01-23 14:13:56 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2024-01-23 14:13:56 +0000
commit92b09d5e799eb5bd56a7858f29f0bf44be3eb049 (patch)
tree757faabedbcb73a0522e54923c8e9dee25a73537 /usr.sbin/ypbind
parent9b45d72621751cdb802de62b9c7a16409b16b8cd (diff)
found some boilerplate strncpy to replace with strlcpy. They are in
messages, but the messages are zero'd first. ok jmatthew
Diffstat (limited to 'usr.sbin/ypbind')
-rw-r--r--usr.sbin/ypbind/ypbind.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/usr.sbin/ypbind/ypbind.c b/usr.sbin/ypbind/ypbind.c
index 6193961f0b7..d8ca66d9571 100644
--- a/usr.sbin/ypbind/ypbind.c
+++ b/usr.sbin/ypbind/ypbind.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypbind.c,v 1.79 2023/11/27 18:37:53 tb Exp $ */
+/* $OpenBSD: ypbind.c,v 1.80 2024/01/23 14:13:55 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993, 1996, 1997, 1998 Theo de Raadt <deraadt@openbsd.org>
@@ -156,8 +156,7 @@ ypbindproc_domain_2x(SVCXPRT *transp, domainname *argp, CLIENT *clnt)
if (ypdb == NULL)
return NULL;
memset(ypdb, 0, sizeof *ypdb);
- strncpy(ypdb->dom_domain, *argp, sizeof ypdb->dom_domain-1);
- ypdb->dom_domain[sizeof ypdb->dom_domain-1] = '\0';
+ strlcpy(ypdb->dom_domain, *argp, sizeof ypdb->dom_domain);
ypdb->dom_vers = YPVERS;
ypdb->dom_alive = 0;
ypdb->dom_lockfd = -1;
@@ -487,8 +486,7 @@ main(int argc, char *argv[])
if (ypbindlist == NULL)
errx(1, "no memory");
memset(ypbindlist, 0, sizeof *ypbindlist);
- strncpy(ypbindlist->dom_domain, domain, sizeof ypbindlist->dom_domain-1);
- ypbindlist->dom_domain[sizeof (ypbindlist->dom_domain)-1] = '\0';
+ strlcpy(ypbindlist->dom_domain, domain, sizeof ypbindlist->dom_domain);
ypbindlist->dom_vers = YPVERS;
snprintf(ypbindlist->dom_servlist, sizeof ypbindlist->dom_servlist,
"%s/%s", SERVERSDIR, ypbindlist->dom_domain);
@@ -960,8 +958,7 @@ rpc_received(char *dom, struct sockaddr_in *raddrp, int force)
if (ypdb == NULL)
return;
memset(ypdb, 0, sizeof *ypdb);
- strncpy(ypdb->dom_domain, dom, sizeof ypdb->dom_domain-1);
- ypdb->dom_domain[sizeof (ypdb->dom_domain)-1] = '\0';
+ strlcpy(ypdb->dom_domain, dom, sizeof ypdb->dom_domain);
ypdb->dom_lockfd = -1;
ypdb->dom_xid = unique_xid(ypdb);
ypdb->dom_pnext = ypbindlist;