From bfb109df293a8a3f8f86d9854f4737dbb7374b79 Mon Sep 17 00:00:00 2001 From: Bill Paul Date: Thu, 9 Oct 1997 20:29:39 +0000 Subject: [PATCH] Fix bug in __yp_ping(): keep proper count of assigned request structures. The test to see if a request struct had been assigned after looping though the server list was bogus. Submitted by: "Erik E. Rantapaa" --- usr.sbin/ypbind/yp_ping.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.sbin/ypbind/yp_ping.c b/usr.sbin/ypbind/yp_ping.c index b9386cba3a8..31df5b832f3 100644 --- a/usr.sbin/ypbind/yp_ping.c +++ b/usr.sbin/ypbind/yp_ping.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: yp_ping.c,v 1.2 1997/05/25 18:54:11 wpaul Exp wpaul $ + * $Id: yp_ping.c,v 1.1 1997/05/25 19:49:29 wpaul Exp $ */ /* @@ -71,7 +71,7 @@ #ifndef lint /*static char *sccsid = "from: @(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC";*/ -static const char rcsid[] = "@(#) $Id: yp_ping.c,v 1.2 1997/05/25 18:54:11 wpaul Exp wpaul $"; +static const char rcsid[] = "@(#) $Id: yp_ping.c,v 1.1 1997/05/25 19:49:29 wpaul Exp $"; #endif /* @@ -458,6 +458,7 @@ int __yp_ping(restricted_addrs, cnt, dom, port) char *foo = dom; struct cu_data *cu; enum clnt_stat (*oldfunc)(); + int validsrvs = 0; /* Set up handles. */ reqs = calloc(1, sizeof(struct ping_req *) * cnt); @@ -477,10 +478,11 @@ int __yp_ping(restricted_addrs, cnt, dom, port) any = &reqs[i]->sin; reqs[i]->xid = xid_seed; xid_seed++; + validsrvs++; } /* Make sure at least one server was assigned */ - if (reqs[0] == NULL) { + if (!validsrvs) { free(reqs); return(-1); }