found some boilerplate strncpy to replace with strlcpy. They are in
authorderaadt <deraadt@openbsd.org>
Tue, 23 Jan 2024 14:13:55 +0000 (14:13 +0000)
committerderaadt <deraadt@openbsd.org>
Tue, 23 Jan 2024 14:13:55 +0000 (14:13 +0000)
messages, but the messages are zero'd first.
ok jmatthew

usr.sbin/ypbind/ypbind.c

index 6193961..d8ca66d 100644 (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;