[Midnightbsd-cvs] src [10307] trunk/usr.sbin/ypbind: sync with freebsd 10
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Jun 3 14:55:20 EDT 2018
Revision: 10307
http://svnweb.midnightbsd.org/src/?rev=10307
Author: laffer1
Date: 2018-06-03 14:55:19 -0400 (Sun, 03 Jun 2018)
Log Message:
-----------
sync with freebsd 10
Modified Paths:
--------------
trunk/usr.sbin/ypbind/yp_ping.c
trunk/usr.sbin/ypbind/ypbind.c
Modified: trunk/usr.sbin/ypbind/yp_ping.c
===================================================================
--- trunk/usr.sbin/ypbind/yp_ping.c 2018-06-03 18:54:51 UTC (rev 10306)
+++ trunk/usr.sbin/ypbind/yp_ping.c 2018-06-03 18:55:19 UTC (rev 10307)
@@ -30,35 +30,33 @@
* SUCH DAMAGE.
*/
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
+/*-
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * All rights reserved.
*
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
-
#if 0
#ifndef lint
static char *sccsid = "@(#)from: clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
@@ -228,7 +226,7 @@
int validsrvs = 0;
/* Set up handles. */
- reqs = calloc(1, sizeof(struct ping_req *) * cnt);
+ reqs = calloc(cnt, sizeof(struct ping_req *));
xid_seed = time(NULL) ^ getpid();
for (i = 0; i < cnt; i++) {
Modified: trunk/usr.sbin/ypbind/ypbind.c
===================================================================
--- trunk/usr.sbin/ypbind/ypbind.c 2018-06-03 18:54:51 UTC (rev 10306)
+++ trunk/usr.sbin/ypbind/ypbind.c 2018-06-03 18:55:19 UTC (rev 10307)
@@ -199,7 +199,12 @@
res.ypbind_resp_u.ypbind_error = YPBIND_ERR_RESC;
return (&res);
}
- ypdb = (struct _dom_binding *)malloc(sizeof *ypdb);
+ if (strlen(*argp) > YPMAXDOMAIN) {
+ syslog(LOG_WARNING, "domain %s too long", *argp);
+ res.ypbind_resp_u.ypbind_error = YPBIND_ERR_RESC;
+ return (&res);
+ }
+ ypdb = malloc(sizeof *ypdb);
if (ypdb == NULL) {
syslog(LOG_WARNING, "malloc: %m");
res.ypbind_resp_u.ypbind_error = YPBIND_ERR_RESC;
@@ -206,7 +211,7 @@
return (&res);
}
bzero(ypdb, sizeof *ypdb);
- strncpy(ypdb->dom_domain, *argp, sizeof ypdb->dom_domain);
+ strlcpy(ypdb->dom_domain, *argp, sizeof ypdb->dom_domain);
ypdb->dom_vers = YPVERS;
ypdb->dom_alive = 0;
ypdb->dom_default = 0;
@@ -392,7 +397,7 @@
if (flock(yplockfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK)
errx(1, "another ypbind is already running. Aborting");
- /* XXX domainname will be overriden if we use restricted mode */
+ /* XXX domainname will be overridden if we use restricted mode */
yp_get_default_domain(&domain_name);
if (domain_name[0] == '\0')
errx(1, "domainname not set. Aborting");
@@ -412,6 +417,9 @@
errx(1, "unknown option: %s", argv[i]);
}
+ if (strlen(domain_name) > YPMAXDOMAIN)
+ warnx("truncating domain name %s", domain_name);
+
/* blow away everything in BINDINGDIR (if it exists) */
if ((dird = opendir(BINDINGDIR)) != NULL) {
@@ -448,11 +456,11 @@
errx(1, "unable to register (YPBINDPROG, YPBINDVERS, tcp)");
/* build initial domain binding, make it "unsuccessful" */
- ypbindlist = (struct _dom_binding *)malloc(sizeof *ypbindlist);
+ ypbindlist = malloc(sizeof *ypbindlist);
if (ypbindlist == NULL)
errx(1, "malloc");
bzero(ypbindlist, sizeof *ypbindlist);
- strncpy(ypbindlist->dom_domain, domain_name, sizeof ypbindlist->dom_domain);
+ strlcpy(ypbindlist->dom_domain, domain_name, sizeof ypbindlist->dom_domain);
ypbindlist->dom_vers = YPVERS;
ypbindlist->dom_alive = 0;
ypbindlist->dom_lockfd = -1;
@@ -883,13 +891,17 @@
if (ypdb == NULL) {
if (force == 0)
return;
- ypdb = (struct _dom_binding *)malloc(sizeof *ypdb);
+ if (strlen(dom) > YPMAXDOMAIN) {
+ syslog(LOG_WARNING, "domain %s too long", dom);
+ return;
+ }
+ ypdb = malloc(sizeof *ypdb);
if (ypdb == NULL) {
syslog(LOG_WARNING, "malloc: %m");
return;
}
bzero(ypdb, sizeof *ypdb);
- strncpy(ypdb->dom_domain, dom, sizeof ypdb->dom_domain);
+ strlcpy(ypdb->dom_domain, dom, sizeof ypdb->dom_domain);
ypdb->dom_lockfd = -1;
ypdb->dom_default = 0;
ypdb->dom_pnext = ypbindlist;
More information about the Midnightbsd-cvs
mailing list