[tor-commits] [torsocks/master] Fix: handle hints being NULL in getaddrinfo
dgoulet at torproject.org
dgoulet at torproject.org
Fri Apr 4 22:40:27 UTC 2014
commit ec15af6e76a541caaf69ffdbae248d1712f69d31
Author: David Goulet <dgoulet at ev0ke.net>
Date: Thu Feb 20 11:41:34 2014 +0000
Fix: handle hints being NULL in getaddrinfo
Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
src/lib/getaddrinfo.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/lib/getaddrinfo.c b/src/lib/getaddrinfo.c
index a0f5595..da9d4ed 100644
--- a/src/lib/getaddrinfo.c
+++ b/src/lib/getaddrinfo.c
@@ -48,6 +48,22 @@ LIBC_GETADDRINFO_RET_TYPE tsocks_getaddrinfo(LIBC_GETADDRINFO_SIG)
goto error;
}
+ /*
+ * Quoting the getaddrinfo(3) man page:
+ *
+ * All the other fields in the structure pointed to by hints must
+ * contain either 0 or a NULL pointer, as appropriate. Specifying hints
+ * as NULL is equivalent to setting ai_socktype and ai_protocol to
+ * 0; ai_family to AF_UNSPEC; and ai_flags to (AI_V4MAPPED |
+ * AI_ADDRCONFIG).
+ *
+ * This means that for sure the ai_family will be treated as AF_UNSPEC.
+ */
+ if (!hints) {
+ tmp_node = node;
+ goto libc_call;
+ }
+
/* Use right domain for the next step. */
switch (hints->ai_family) {
default:
@@ -83,6 +99,7 @@ LIBC_GETADDRINFO_RET_TYPE tsocks_getaddrinfo(LIBC_GETADDRINFO_SIG)
DBG("[getaddrinfo] Node %s will be passed to the libc call", tmp_node);
}
+libc_call:
ret = tsocks_libc_getaddrinfo(tmp_node, service, hints, res);
if (ret) {
goto error;
More information about the tor-commits
mailing list