summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-06-01 00:55:27 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-06-01 00:55:27 +0200
commit60b7732c3eca2f7743db6595b92763f75c88c1a4 (patch)
treed6acd19a80509b17b6ca345733429d3f1ed197b4 /src
parent10496d2dc9c0f0ba46f7af387ede9fb8690bbfc4 (diff)
downloadfastd-60b7732c3eca2f7743db6595b92763f75c88c1a4.tar
fastd-60b7732c3eca2f7743db6595b92763f75c88c1a4.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/resolve.c4
1 files changed, 2 insertions, 2 deletions
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;
}