Skip to content

Commit

Permalink
set errno when DNS resolution fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
ohmori7 committed Jan 19, 2014
1 parent 954beea commit 2a2b431
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/kcn_sockaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,18 @@ kcn_sockaddr_aton(struct sockaddr_storage *ss,
hai.ai_protocol = 0;
error = getaddrinfo(nodename, servname, &hai, &rai);
if (error != 0)
goto out;
goto bad;
assert(rai != NULL);
assert(sizeof(*ss) >= rai->ai_addrlen);
memcpy(ss, rai->ai_addr, rai->ai_addrlen);
freeaddrinfo(rai);
out:
return error == 0 ? true : false;
return true;
bad:
if (error == EAI_AGAIN)
errno = EAGAIN;
else if (error != EAI_SYSTEM)
errno = EINVAL;
return false;
}

bool
Expand Down

0 comments on commit 2a2b431

Please sign in to comment.