summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2014-05-17 19:13:27 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-05-20 21:07:35 +0200
commit7aaf9138ccf7ab73883f28cfafd6e508d29ffa67 (patch)
treede0e0f1bfb1edb1913d3f2e9c24d42e5bba8e864
parent4084ccd3442917c7aa88ba4d76ba1e71e67d3846 (diff)
downloadsssd-7aaf9138ccf7ab73883f28cfafd6e508d29ffa67.tar.gz
sssd-7aaf9138ccf7ab73883f28cfafd6e508d29ffa67.tar.xz
sssd-7aaf9138ccf7ab73883f28cfafd6e508d29ffa67.zip
resolv: Do not try to free addrinfo in case of error
We should call freeaddrinfo only in situation if getaddrinfo succeeds. It is not specified in RFC2553 the behaviour of calling freeaddrinfo with the NULL argument. It is more portable to do not rely on undocumented behaviour of glibc. http://www.ietf.org/rfc/rfc2553.txt [Page 28] Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
-rw-r--r--src/resolv/async_resolv.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/resolv/async_resolv.c b/src/resolv/async_resolv.c
index f0361ce8c..38fa84d9f 100644
--- a/src/resolv/async_resolv.c
+++ b/src/resolv/async_resolv.c
@@ -1151,7 +1151,6 @@ resolv_is_address(const char *name)
hints.ai_flags = AI_NUMERICHOST; /* No network lookups */
ret = getaddrinfo(name, NULL, &hints, &res);
- freeaddrinfo(res);
if (ret != 0) {
if (ret == -2) {
DEBUG(SSSDBG_TRACE_ALL,
@@ -1160,6 +1159,8 @@ resolv_is_address(const char *name)
DEBUG(SSSDBG_OP_FAILURE, "getaddrinfo failed [%d]: %s\n",
ret, gai_strerror(ret));
}
+ } else { /* ret == 0 */
+ freeaddrinfo(res);
}
return ret == 0;