diff options
| author | Vitaly Magerya <vmagerya@gmail.com> | 2011-03-22 20:14:26 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-22 20:14:26 +0100 |
| commit | 7f4b769c42f3773ff2e2e749547291dcb7e85d01 (patch) | |
| tree | 33680f1d1a6d182c2d78dd2158ee696528fea920 | |
| parent | cf9074b54bfb5a325ce59127b7afe1e892223a1c (diff) | |
| download | busybox-w32-7f4b769c42f3773ff2e2e749547291dcb7e85d01.tar.gz busybox-w32-7f4b769c42f3773ff2e2e749547291dcb7e85d01.tar.bz2 busybox-w32-7f4b769c42f3773ff2e2e749547291dcb7e85d01.zip | |
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.c | 16 | ||||
| -rw-r--r-- | libbb/xconnect.c | 5 | ||||
| -rw-r--r-- | networking/nslookup.c | 4 |
3 files changed, 14 insertions, 11 deletions
diff --git a/libbb/inet_common.c b/libbb/inet_common.c index 6f585ebd9..207720e96 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 | |||
| 164 | 164 | ||
| 165 | int FAST_FUNC INET6_resolve(const char *name, struct sockaddr_in6 *sin6) | 165 | int FAST_FUNC INET6_resolve(const char *name, struct sockaddr_in6 *sin6) |
| 166 | { | 166 | { |
| 167 | struct addrinfo req, *ai; | 167 | struct addrinfo req, *ai = NULL; |
| 168 | int s; | 168 | int s; |
| 169 | 169 | ||
| 170 | memset(&req, '\0', sizeof req); | 170 | memset(&req, 0, sizeof(req)); |
| 171 | req.ai_family = AF_INET6; | 171 | req.ai_family = AF_INET6; |
| 172 | s = getaddrinfo(name, NULL, &req, &ai); | 172 | s = getaddrinfo(name, NULL, &req, &ai); |
| 173 | if (s) { | 173 | if (s != 0) { |
| 174 | bb_error_msg("getaddrinfo: %s: %d", name, s); | 174 | bb_error_msg("getaddrinfo: %s: %d", name, s); |
| 175 | return -1; | 175 | return -1; |
| 176 | } | 176 | } |
| 177 | memcpy(sin6, ai->ai_addr, sizeof(struct sockaddr_in6)); | 177 | memcpy(sin6, ai->ai_addr, sizeof(*sin6)); |
| 178 | freeaddrinfo(ai); | 178 | freeaddrinfo(ai); |
| 179 | return 0; | 179 | return 0; |
| 180 | } | 180 | } |
| @@ -209,9 +209,11 @@ char* FAST_FUNC INET6_rresolve(struct sockaddr_in6 *sin6, int numeric) | |||
| 209 | return xstrdup("*"); | 209 | return xstrdup("*"); |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | s = getnameinfo((struct sockaddr *) sin6, sizeof(struct sockaddr_in6), | 212 | s = getnameinfo((struct sockaddr *) sin6, sizeof(*sin6), |
| 213 | name, sizeof(name), NULL, 0, 0); | 213 | name, sizeof(name), |
| 214 | if (s) { | 214 | /*serv,servlen:*/ NULL, 0, |
| 215 | 0); | ||
| 216 | if (s != 0) { | ||
| 215 | bb_error_msg("getnameinfo failed"); | 217 | bb_error_msg("getnameinfo failed"); |
| 216 | return NULL; | 218 | return NULL; |
| 217 | } | 219 | } |
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 3a6585caa..127e2a5fc 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
| @@ -255,7 +255,7 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;) | |||
| 255 | 255 | ||
| 256 | memset(&hint, 0 , sizeof(hint)); | 256 | memset(&hint, 0 , sizeof(hint)); |
| 257 | hint.ai_family = af; | 257 | hint.ai_family = af; |
| 258 | /* Needed. Or else we will get each address thrice (or more) | 258 | /* Need SOCK_STREAM, or else we get each address thrice (or more) |
| 259 | * for each possible socket type (tcp,udp,raw...): */ | 259 | * for each possible socket type (tcp,udp,raw...): */ |
| 260 | hint.ai_socktype = SOCK_STREAM; | 260 | hint.ai_socktype = SOCK_STREAM; |
| 261 | hint.ai_flags = ai_flags & ~DIE_ON_ERROR; | 261 | hint.ai_flags = ai_flags & ~DIE_ON_ERROR; |
| @@ -285,7 +285,8 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;) | |||
| 285 | set_port: | 285 | set_port: |
| 286 | set_nport(r, htons(port)); | 286 | set_nport(r, htons(port)); |
| 287 | ret: | 287 | ret: |
| 288 | freeaddrinfo(result); | 288 | if (result) |
| 289 | freeaddrinfo(result); | ||
| 289 | return r; | 290 | return r; |
| 290 | } | 291 | } |
| 291 | #if !ENABLE_FEATURE_IPV6 | 292 | #if !ENABLE_FEATURE_IPV6 |
diff --git a/networking/nslookup.c b/networking/nslookup.c index dcac7379e..67fc01547 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c | |||
| @@ -66,7 +66,7 @@ static int print_host(const char *hostname, const char *header) | |||
| 66 | // hint.ai_flags = AI_CANONNAME; | 66 | // hint.ai_flags = AI_CANONNAME; |
| 67 | rc = getaddrinfo(hostname, NULL /*service*/, &hint, &result); | 67 | rc = getaddrinfo(hostname, NULL /*service*/, &hint, &result); |
| 68 | 68 | ||
| 69 | if (!rc) { | 69 | if (rc == 0) { |
| 70 | struct addrinfo *cur = result; | 70 | struct addrinfo *cur = result; |
| 71 | unsigned cnt = 0; | 71 | unsigned cnt = 0; |
| 72 | 72 | ||
| @@ -94,7 +94,7 @@ static int print_host(const char *hostname, const char *header) | |||
| 94 | bb_error_msg("can't resolve '%s'", hostname); | 94 | bb_error_msg("can't resolve '%s'", hostname); |
| 95 | #endif | 95 | #endif |
| 96 | } | 96 | } |
| 97 | if (ENABLE_FEATURE_CLEAN_UP) | 97 | if (ENABLE_FEATURE_CLEAN_UP && result) |
| 98 | freeaddrinfo(result); | 98 | freeaddrinfo(result); |
| 99 | return (rc != 0); | 99 | return (rc != 0); |
| 100 | } | 100 | } |
