summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Magerya <vmagerya@gmail.com>2011-03-22 19:14:26 (GMT)
committer Denys Vlasenko <vda.linux@googlemail.com>2011-03-22 19:14:26 (GMT)
commit7f4b769c42f3773ff2e2e749547291dcb7e85d01 (patch)
tree33680f1d1a6d182c2d78dd2158ee696528fea920
parentcf9074b54bfb5a325ce59127b7afe1e892223a1c (diff)
downloadbusybox-7f4b769c42f3773ff2e2e749547291dcb7e85d01.tar.gz
busybox-7f4b769c42f3773ff2e2e749547291dcb7e85d01.tar.bz2
don't call freeaddinfo(NULL)
Signed-off-by: Vitaly Magerya <vmagerya@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/inet_common.c16
-rw-r--r--libbb/xconnect.c5
-rw-r--r--networking/nslookup.c4
3 files changed, 14 insertions, 11 deletions
diff --git a/libbb/inet_common.c b/libbb/inet_common.c
index 6f585eb..207720e 100644
--- a/libbb/inet_common.c
+++ b/libbb/inet_common.c
@@ -164,17 +164,17 @@ char* FAST_FUNC INET_rresolve(struct sockaddr_in *s_in, int numeric, uint32_t ne
int FAST_FUNC INET6_resolve(const char *name, struct sockaddr_in6 *sin6)
{
- struct addrinfo req, *ai;
+ struct addrinfo req, *ai = NULL;
int s;
- memset(&req, '\0', sizeof req);
+ memset(&req, 0, sizeof(req));
req.ai_family = AF_INET6;
s = getaddrinfo(name, NULL, &req, &ai);
- if (s) {
+ if (s != 0) {
bb_error_msg("getaddrinfo: %s: %d", name, s);
return -1;
}
- memcpy(sin6, ai->ai_addr, sizeof(struct sockaddr_in6));
+ memcpy(sin6, ai->ai_addr, sizeof(*sin6));
freeaddrinfo(ai);
return 0;
}
@@ -209,9 +209,11 @@ char* FAST_FUNC INET6_rresolve(struct sockaddr_in6 *sin6, int numeric)
return xstrdup("*");
}
- s = getnameinfo((struct sockaddr *) sin6, sizeof(struct sockaddr_in6),
- name, sizeof(name), NULL, 0, 0);
- if (s) {
+ s = getnameinfo((struct sockaddr *) sin6, sizeof(*sin6),
+ name, sizeof(name),
+ /*serv,servlen:*/ NULL, 0,
+ 0);
+ if (s != 0) {
bb_error_msg("getnameinfo failed");
return NULL;
}
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index 3a6585c..127e2a5 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -255,7 +255,7 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;)
memset(&hint, 0 , sizeof(hint));
hint.ai_family = af;
- /* Needed. Or else we will get each address thrice (or more)
+ /* Need SOCK_STREAM, or else we get each address thrice (or more)
* for each possible socket type (tcp,udp,raw...): */
hint.ai_socktype = SOCK_STREAM;
hint.ai_flags = ai_flags & ~DIE_ON_ERROR;
@@ -285,7 +285,8 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;)
set_port:
set_nport(r, htons(port));
ret:
- freeaddrinfo(result);
+ if (result)
+ freeaddrinfo(result);
return r;
}
#if !ENABLE_FEATURE_IPV6
diff --git a/networking/nslookup.c b/networking/nslookup.c
index dcac737..67fc015 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -66,7 +66,7 @@ static int print_host(const char *hostname, const char *header)
// hint.ai_flags = AI_CANONNAME;
rc = getaddrinfo(hostname, NULL /*service*/, &hint, &result);
- if (!rc) {
+ if (rc == 0) {
struct addrinfo *cur = result;
unsigned cnt = 0;
@@ -94,7 +94,7 @@ static int print_host(const char *hostname, const char *header)
bb_error_msg("can't resolve '%s'", hostname);
#endif
}
- if (ENABLE_FEATURE_CLEAN_UP)
+ if (ENABLE_FEATURE_CLEAN_UP && result)
freeaddrinfo(result);
return (rc != 0);
}