NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: PR/50367 CVS commit: src/lib/libc/net



Shouldn't the sister file getnetnamadr.c be changed as well? Something along this line:

Index: lib/libc/net/getnetnamadr.c
===================================================================
RCS file: /cvsroot/src/lib/libc/net/getnetnamadr.c,v
retrieving revision 1.42
diff -u -p -r1.42 getnetnamadr.c
--- lib/libc/net/getnetnamadr.c	13 Mar 2012 21:13:41 -0000	1.42
+++ lib/libc/net/getnetnamadr.c	26 Oct 2015 17:28:21 -0000
@@ -77,6 +77,12 @@ __weak_alias(getnetbyaddr,_getnetbyaddr)
 __weak_alias(getnetbyname,_getnetbyname)
 #endif
 
+#define maybe_ok(res, nm, ok) (((res)->options & RES_NOCHECKNAME) != 0U || \
+                               (ok)(nm) != 0)
+#define maybe_hnok(res, hn) maybe_ok((res), (hn), res_hnok)
+#define maybe_dnok(res, dn) maybe_ok((res), (dn), res_dnok)
+
+
 extern int _net_stayopen;
 
 #define BYADDR 0
@@ -105,7 +111,7 @@ static	struct netent net_entry;
 static	char *net_aliases[MAXALIASES];
 
 static int		parse_reversed_addr(const char *, in_addr_t *);
-static struct netent	*getnetanswer(querybuf *, int, int);
+static struct netent	*getnetanswer(res_state, querybuf *, int, int);
 static int		_files_getnetbyaddr(void *, void *, va_list);
 static int		_files_getnetbyname(void *, void *, va_list);
 static int		_dns_getnetbyaddr(void *, void *, va_list);
@@ -159,7 +165,7 @@ parse_reversed_addr(const char *str, in_
 }
 
 static struct netent *
-getnetanswer(querybuf *answer, int anslen, int net_i)
+getnetanswer(res_state res,querybuf *answer, int anslen, int net_i)
 {
 	static char	n_name[MAXDNAME];
 	static char	netbuf[PACKETSZ];
@@ -172,6 +178,7 @@ getnetanswer(querybuf *answer, int ansle
 	char		*in, *bp, **ap, *ep;
 
 	_DIAGASSERT(answer != NULL);
+	_DIAGASSERT(res != NULL);
 
 	/*
 	 * find first satisfactory answer
@@ -216,7 +223,7 @@ getnetanswer(querybuf *answer, int ansle
 	n_name[0] = '\0';
 	while (--ancount >= 0 && cp < eom) {
 		n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp));
-		if ((n < 0) || !res_dnok(bp))
+		if ((n < 0) || !maybe_dnok(res, bp))
 			break;
 		cp += n;
 		(void)strlcpy(n_name, bp, sizeof(n_name));
@@ -226,7 +233,7 @@ getnetanswer(querybuf *answer, int ansle
 		GETSHORT(n, cp);
 		if (class == C_IN && type == T_PTR) {
 			n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp));
-			if ((n < 0) || !res_hnok(bp)) {
+			if ((n < 0) || !maybe_hnok(res, bp)) {
 				cp += n;
 				return NULL;
 			}
@@ -359,7 +366,7 @@ _dns_getnetbyaddr(void *cbrv, void *cbda
 		return NS_NOTFOUND;
 	}
 	__res_put_state(res);
-	np = getnetanswer(buf, anslen, BYADDR);
+	np = getnetanswer(res, buf, anslen, BYADDR);
 	free(buf);
 	if (np) {
 		/* maybe net should be unsigned? */
@@ -471,7 +478,7 @@ _dns_getnetbyname(void *cbrv, void *cbda
 		return NS_NOTFOUND;
 	}
 	__res_put_state(res);
-	np = getnetanswer(buf, anslen, BYNAME);
+	np = getnetanswer(res, buf, anslen, BYNAME);
 	free(buf);
 
 	if (np != NULL) {


Home | Main Index | Thread Index | Old Index