Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7-0]: src/lib/libc/net Pull up to netbsd-7 (missing part of ticke...
details: https://anonhg.NetBSD.org/src/rev/1688b31f2b20
branches: netbsd-7-0
changeset: 801112:1688b31f2b20
user: sborrill <sborrill%NetBSD.org@localhost>
date: Fri Jan 15 18:09:19 2016 +0000
description:
Pull up to netbsd-7 (missing part of ticket #1012):
lib/libc/net/getaddrinfo.c 1.110
diffstat:
lib/libc/net/getaddrinfo.c | 39 +++++++++++++++------------------------
1 files changed, 15 insertions(+), 24 deletions(-)
diffs (137 lines):
diff -r d9dd2ab8158f -r 1688b31f2b20 lib/libc/net/getaddrinfo.c
--- a/lib/libc/net/getaddrinfo.c Tue Jan 12 10:27:48 2016 +0000
+++ b/lib/libc/net/getaddrinfo.c Fri Jan 15 18:09:19 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getaddrinfo.c,v 1.106 2013/12/22 02:40:48 christos Exp $ */
+/* $NetBSD: getaddrinfo.c,v 1.106.6.1 2016/01/15 18:09:19 sborrill Exp $ */
/* $KAME: getaddrinfo.c,v 1.29 2000/08/31 17:26:57 itojun Exp $ */
/*
@@ -55,7 +55,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getaddrinfo.c,v 1.106 2013/12/22 02:40:48 christos Exp $");
+__RCSID("$NetBSD: getaddrinfo.c,v 1.106.6.1 2016/01/15 18:09:19 sborrill Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -221,8 +221,8 @@
static int ip6_str2scopeid(char *, struct sockaddr_in6 *, u_int32_t *);
#endif
-static struct addrinfo *getanswer(const querybuf *, int, const char *, int,
- const struct addrinfo *);
+static struct addrinfo *getanswer(res_state, const querybuf *, int,
+ const char *, int, const struct addrinfo *);
static void aisort(struct addrinfo *s, res_state res);
static struct addrinfo * _dns_query(struct res_target *,
const struct addrinfo *, res_state, int);
@@ -1157,9 +1157,11 @@
static const char AskedForGot[] =
"gethostby*.getanswer: asked for \"%s\", got \"%s\"";
+#define maybe_ok(res, nm, ok) (((res)->options & RES_NOCHECKNAME) != 0U || \
+ (ok)(nm) != 0)
static struct addrinfo *
-getanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
- const struct addrinfo *pai)
+getanswer(res_state res, const querybuf *answer, int anslen, const char *qname,
+ int qtype, const struct addrinfo *pai)
{
struct addrinfo sentinel, *cur;
struct addrinfo ai, *aip;
@@ -1181,6 +1183,7 @@
_DIAGASSERT(answer != NULL);
_DIAGASSERT(qname != NULL);
_DIAGASSERT(pai != NULL);
+ _DIAGASSERT(res != NULL);
memset(&sentinel, 0, sizeof(sentinel));
cur = &sentinel;
@@ -1213,7 +1216,7 @@
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);
}
@@ -1238,7 +1241,7 @@
srvlist = NULL;
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;
}
@@ -1257,7 +1260,7 @@
if ((qtype == T_A || qtype == T_AAAA || qtype == T_ANY) &&
type == T_CNAME) {
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;
}
@@ -1348,7 +1351,7 @@
cp += INT16SZ;
n = dn_expand(answer->buf, eom, cp, tbuf,
(int)sizeof(tbuf));
- if ((n < 0) || !res_hnok(tbuf)) {
+ if ((n < 0) || !maybe_ok(res, tbuf, res_hnok)) {
had_error++;
continue;
}
@@ -1394,7 +1397,6 @@
}
if (srvlist) {
- res_state res;
/*
* Check for explicit rejection.
*/
@@ -1403,16 +1405,6 @@
h_errno = HOST_NOT_FOUND;
return NULL;
}
- res = __res_get_state();
- if (res == NULL) {
- while (srvlist != NULL) {
- srv = srvlist;
- srvlist = srvlist->next;
- free(srv);
- }
- h_errno = NETDB_INTERNAL;
- return NULL;
- }
while (srvlist) {
struct res_target q, q2;
@@ -1447,7 +1439,6 @@
}
free(srv);
}
- __res_put_state(res);
}
if (haveanswer) {
if (!sentinel.ai_next->ai_canonname)
@@ -1536,14 +1527,14 @@
goto out;
}
- ai = getanswer(buf, q->n, q->name, q->qtype, pai);
+ ai = getanswer(res, buf, q->n, q->name, q->qtype, pai);
if (ai) {
cur->ai_next = ai;
while (cur && cur->ai_next)
cur = cur->ai_next;
}
if (q2) {
- ai = getanswer(buf2, q2->n, q2->name, q2->qtype, pai);
+ ai = getanswer(res, buf2, q2->n, q2->name, q2->qtype, pai);
if (ai)
cur->ai_next = ai;
}
Home |
Main Index |
Thread Index |
Old Index