Module Name:    src
Committed By:   christos
Date:           Sun Sep  9 16:42:23 UTC 2012

Modified Files:
        src/lib/libc/net: gethnamaddr.c

Log Message:
implement no-check-names


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/lib/libc/net/gethnamaddr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/net/gethnamaddr.c
diff -u src/lib/libc/net/gethnamaddr.c:1.78 src/lib/libc/net/gethnamaddr.c:1.79
--- src/lib/libc/net/gethnamaddr.c:1.78	Tue Mar 13 17:13:40 2012
+++ src/lib/libc/net/gethnamaddr.c	Sun Sep  9 12:42:23 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: gethnamaddr.c,v 1.78 2012/03/13 21:13:40 christos Exp $	*/
+/*	$NetBSD: gethnamaddr.c,v 1.79 2012/09/09 16:42:23 christos Exp $	*/
 
 /*
  * ++Copyright++ 1985, 1988, 1993
@@ -57,7 +57,7 @@
 static char sccsid[] = "@(#)gethostnamadr.c	8.1 (Berkeley) 6/4/93";
 static char rcsid[] = "Id: gethnamaddr.c,v 8.21 1997/06/01 20:34:37 vixie Exp ";
 #else
-__RCSID("$NetBSD: gethnamaddr.c,v 1.78 2012/03/13 21:13:40 christos Exp $");
+__RCSID("$NetBSD: gethnamaddr.c,v 1.79 2012/09/09 16:42:23 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -101,6 +101,12 @@ __weak_alias(gethostbyname,_gethostbynam
 __weak_alias(gethostent,_gethostent)
 #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)
+
+
 #define	MAXALIASES	35
 #define	MAXADDRS	35
 
@@ -258,7 +264,7 @@ getanswer(const querybuf *answer, int an
 		return NULL;
 	}
 	n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp));
-	if ((n < 0) || !(*name_ok)(bp)) {
+	if ((n < 0) || !maybe_ok(res, bp, name_ok)) {
 		h_errno = NO_RECOVERY;
 		return NULL;
 	}
@@ -288,7 +294,7 @@ getanswer(const querybuf *answer, int an
 	had_error = 0;
 	while (ancount-- > 0 && cp < eom && !had_error) {
 		n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp));
-		if ((n < 0) || !(*name_ok)(bp)) {
+		if ((n < 0) || !maybe_ok(res, bp, name_ok)) {
 			had_error++;
 			continue;
 		}
@@ -311,7 +317,7 @@ getanswer(const querybuf *answer, int an
 			if (ap >= &host_aliases[MAXALIASES-1])
 				continue;
 			n = dn_expand(answer->buf, eom, cp, tbuf, (int)sizeof tbuf);
-			if ((n < 0) || !(*name_ok)(tbuf)) {
+			if ((n < 0) || !maybe_ok(res, tbuf, name_ok)) {
 				had_error++;
 				continue;
 			}
@@ -341,7 +347,7 @@ getanswer(const querybuf *answer, int an
 		}
 		if (qtype == T_PTR && type == T_CNAME) {
 			n = dn_expand(answer->buf, eom, cp, tbuf, (int)sizeof tbuf);
-			if (n < 0 || !res_dnok(tbuf)) {
+			if (n < 0 || !maybe_dnok(res, tbuf)) {
 				had_error++;
 				continue;
 			}
@@ -379,7 +385,7 @@ getanswer(const querybuf *answer, int an
 				continue;	/* XXX - had_error++ ? */
 			}
 			n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp));
-			if ((n < 0) || !res_hnok(bp)) {
+			if ((n < 0) || !maybe_hnok(res, bp)) {
 				had_error++;
 				break;
 			}

Reply via email to