1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-21 23:18:00 -08:00

found some boilerplate strncpy to replace with strlcpy. They are in

messages, but the messages are zero'd first.
ok jmatthew
This commit is contained in:
deraadt 2024-01-23 14:13:55 +00:00
parent c7248f90fb
commit 55fc36399d

View File

@ -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;