summaryrefslogtreecommitdiffstats
path: root/contrib/bind/lib/irs/nis_ng.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind/lib/irs/nis_ng.c')
-rw-r--r--contrib/bind/lib/irs/nis_ng.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/contrib/bind/lib/irs/nis_ng.c b/contrib/bind/lib/irs/nis_ng.c
index 1667ca6..88d97ff 100644
--- a/contrib/bind/lib/irs/nis_ng.c
+++ b/contrib/bind/lib/irs/nis_ng.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996 by Internet Software Consortium.
+ * Copyright (c) 1996,1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: nis_ng.c,v 1.10 1997/12/04 04:58:00 halley Exp $";
+static const char rcsid[] = "$Id: nis_ng.c,v 1.16 1999/01/18 07:46:58 vixie Exp $";
#endif
/* Imports */
@@ -34,7 +34,7 @@ static int __bind_irs_nis_unneeded;
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
-#include <assert.h>
+#include <isc/assertions.h>
#include <ctype.h>
#include <errno.h>
#include <netdb.h>
@@ -42,6 +42,11 @@ static int __bind_irs_nis_unneeded;
#include <stdlib.h>
#include <string.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+
+#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
@@ -91,13 +96,13 @@ irs_nis_ng(struct irs_acc *this) {
struct irs_ng *ng;
struct pvt *pvt;
- if (!(ng = malloc(sizeof *ng))) {
+ if (!(ng = memget(sizeof *ng))) {
errno = ENOMEM;
return (NULL);
}
memset(ng, 0x5e, sizeof *ng);
- if (!(pvt = (struct pvt *)malloc(sizeof *pvt))) {
- free(ng);
+ if (!(pvt = memget(sizeof *pvt))) {
+ memput(ng, sizeof *ng);
errno = ENOMEM;
return (NULL);
}
@@ -119,14 +124,13 @@ ng_close(struct irs_ng *this) {
struct pvt *pvt = (struct pvt *)this->private;
tmpfree(pvt);
- free(pvt);
- free(this);
+ memput(pvt, sizeof *pvt);
+ memput(this, sizeof *this);
}
static int
ng_next(struct irs_ng *this, char **host, char **user, char **domain) {
struct pvt *pvt = (struct pvt *)this->private;
- struct netgrp *rval;
if (!pvt->cur)
return (0);
@@ -159,7 +163,6 @@ ng_test(struct irs_ng *this, const char *name,
static void
ng_rewind(struct irs_ng *this, const char *name) {
struct pvt *pvt = (struct pvt *)this->private;
- struct netgrp *rval;
/* Either hand back or free the existing list. */
if (pvt->tmpgroup) {
@@ -194,7 +197,10 @@ add_group_to_list(struct pvt *pvt, const char *name, int len) {
r = yp_match(pvt->nis_domain, netgroup_map, (char *)name, len,
&vdata, &vlen);
if (r == 0) {
- for (cp = vdata; cp; cp = np) {
+ cp = vdata;
+ if (*cp && cp[strlen(cp)-1] == '\n')
+ cp[strlen(cp)-1] = '\0';
+ for ( ; cp; cp = np) {
np = strchr(cp, ' ');
if (np)
*np++ = '\0';
@@ -212,7 +218,7 @@ add_tuple_to_list(struct pvt *pvt, const char *name, char *cp) {
struct tmpgrp *tmp;
char *tp, *np;
- assert(*cp++ == '(');
+ INSIST(*cp++ == '(');
tmp = malloc(sizeof *tmp + strlen(name) + sizeof '\0' +
strlen(cp) - sizeof ')');
OpenPOWER on IntegriCloud