From 60b7732c3eca2f7743db6595b92763f75c88c1a4 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 1 Jun 2012 00:55:27 +0200 Subject: Fix a possible crash involving strange resolve returns fastd has been seen crashing on some hosts under strange circumstances. As the bug seems to involve invalid address families, try to assure no unsupported address families are returned from resolver. --- src/resolve.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/resolve.c') diff --git a/src/resolve.c b/src/resolve.c index a054290..20355d7 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -61,11 +61,11 @@ static void* resolve_peer(void *varg) { gai_ret = getaddrinfo(arg->hostname, portstr, &hints, &res); - if (gai_ret) { + if (gai_ret || !res) { pr_debug(arg->ctx, "Resolving host `%s' failed: %s", arg->hostname, gai_strerror(gai_ret)); error = true; } - else if (res->ai_addrlen > sizeof(fastd_peer_address)) { + else if (res->ai_addrlen > sizeof(fastd_peer_address) || (res->ai_addr->sa_family != AF_INET && res->ai_addr->sa_family != AF_INET6)) { pr_warn(arg->ctx, "Resolving host `%s': unsupported address returned", arg->hostname); error = true; } -- cgit v1.2.3