diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-03-25 23:08:58 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-03-25 23:08:58 +0000 |
commit | 18706bb5adc4c9128091873009212164115d8ac7 (patch) | |
tree | 3ae2baf5f08e69aab7eeeadb5978312461fb7171 /usr.sbin/ypbind/ypbind.c | |
parent | 065a6ff2dd6561e7be51cba882090b14f4f4ce1d (diff) |
careful with name lengths and the xid
Diffstat (limited to 'usr.sbin/ypbind/ypbind.c')
-rw-r--r-- | usr.sbin/ypbind/ypbind.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.sbin/ypbind/ypbind.c b/usr.sbin/ypbind/ypbind.c index 3394804545b..ee7c9b9595e 100644 --- a/usr.sbin/ypbind/ypbind.c +++ b/usr.sbin/ypbind/ypbind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypbind.c,v 1.20 1997/02/01 00:26:04 deraadt Exp $ */ +/* $OpenBSD: ypbind.c,v 1.21 1997/03/25 23:08:57 deraadt Exp $ */ /* * Copyright (c) 1996 Theo de Raadt <deraadt@theos.com> @@ -34,7 +34,7 @@ */ #ifndef LINT -static char rcsid[] = "$OpenBSD: ypbind.c,v 1.20 1997/02/01 00:26:04 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: ypbind.c,v 1.21 1997/03/25 23:08:57 deraadt Exp $"; #endif #include <sys/param.h> @@ -169,7 +169,8 @@ ypbindproc_domain_2x(transp, argp, clnt) if (ypdb == NULL) { ypdb = (struct _dom_binding *)malloc(sizeof *ypdb); memset(ypdb, 0, sizeof *ypdb); - strncpy(ypdb->dom_domain, *argp, sizeof ypdb->dom_domain); + strncpy(ypdb->dom_domain, *argp, sizeof ypdb->dom_domain-1); + ypdb->dom_domain[sizeof ypdb->dom_domain-1] = '\0'; ypdb->dom_vers = YPVERS; ypdb->dom_alive = 0; ypdb->dom_lockfd = -1; @@ -501,10 +502,12 @@ main(argc, argv) /* build initial domain binding, make it "unsuccessful" */ ypbindlist = (struct _dom_binding *)malloc(sizeof *ypbindlist); memset(ypbindlist, 0, sizeof *ypbindlist); - strncpy(ypbindlist->dom_domain, domain, sizeof ypbindlist->dom_domain); + strncpy(ypbindlist->dom_domain, domain, sizeof ypbindlist->dom_domain-1); + ypbindlist->dom_domain[sizeof ypbindlist->dom_domain)-1] = '\0'; ypbindlist->dom_vers = YPVERS; ypbindlist->dom_alive = 0; ypbindlist->dom_lockfd = -1; + ypbindlist->dom_xid = unique_xid(ypbindlist); sprintf(path, "%s/%s.%d", BINDINGDIR, ypbindlist->dom_domain, (int)ypbindlist->dom_vers); (void)unlink(path); @@ -1003,7 +1006,8 @@ int force; return; ypdb = (struct _dom_binding *)malloc(sizeof *ypdb); memset(ypdb, 0, sizeof *ypdb); - strncpy(ypdb->dom_domain, dom, sizeof ypdb->dom_domain); + strncpy(ypdb->dom_domain, dom, sizeof ypdb->dom_domain-1); + ypdb->dom_domain[sizeof ypdb->dom_domain)-1] = '\0'; ypdb->dom_lockfd = -1; ypdb->dom_pnext = ypbindlist; ypbindlist = ypdb; |