-/* $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>
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;
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);
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;