1 From 290f19972e9f7b74f818ae211cb535e32f1f314f Mon Sep 17 00:00:00 2001
2 From: Leonid Evdokimov <leon@darkk.net.ru>
3 Date: Tue, 10 Apr 2012 00:57:26 +0400
4 Subject: [PATCH 01/12] Fix bug in DNS resolution - results were ignored (since
8 parser.c | 10 +++++-----
9 1 file changed, 5 insertions(+), 5 deletions(-)
11 diff --git a/parser.c b/parser.c
12 index 85d3533..6198828 100644
15 @@ -295,22 +295,22 @@ static int vp_in_addr(parser_context *context, void *addr, const char *token)
16 memcpy(addr, &ia, sizeof(ia));
19 - struct addrinfo *addr, hints;
20 + struct addrinfo *ainfo, hints;
22 memset(&hints, 0, sizeof(hints));
23 hints.ai_family = AF_INET; /* IPv4-only */
24 hints.ai_socktype = SOCK_STREAM; /* I want to have one address once and ONLY once, that's why I specify socktype and protocol */
25 hints.ai_protocol = IPPROTO_TCP;
26 hints.ai_flags = AI_ADDRCONFIG; /* I don't need IPv4 addrs without IPv4 connectivity */
27 - err = getaddrinfo(token, NULL, &hints, &addr);
28 + err = getaddrinfo(token, NULL, &hints, &ainfo);
31 struct addrinfo *iter;
32 struct sockaddr_in *resolved_addr;
33 - for (iter = addr, count = 0; iter; iter = iter->ai_next, ++count)
34 + for (iter = ainfo, count = 0; iter; iter = iter->ai_next, ++count)
36 taken = rand() % count;
37 - for (iter = addr; taken > 0; iter = iter->ai_next, --taken)
38 + for (iter = ainfo; taken > 0; iter = iter->ai_next, --taken)
40 resolved_addr = (struct sockaddr_in*)iter->ai_addr;
41 assert(resolved_addr->sin_family == iter->ai_family && iter->ai_family == AF_INET);
42 @@ -318,7 +318,7 @@ static int vp_in_addr(parser_context *context, void *addr, const char *token)
43 log_error(LOG_WARNING, "%s resolves to %d addresses, using %s",
44 token, count, inet_ntoa(resolved_addr->sin_addr));
45 memcpy(addr, &resolved_addr->sin_addr, sizeof(ia));
47 + freeaddrinfo(ainfo);
50 if (err == EAI_SYSTEM)