Skip to content

Commit

Permalink
Ignore failed addressinfo from_host_alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHX committed Sep 4, 2020
1 parent f592770 commit b1514ae
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,27 @@ bionic::addrinfo* bionic::from_host_alloc(const ::addrinfo *in) {
return nullptr;

auto out = new addrinfo;
out->ai_flags = from_host_ai_flags(in->ai_flags);
out->ai_family = from_host_af_family(in->ai_family);
out->ai_socktype = from_host_socktype(in->ai_socktype);
out->ai_protocol = from_host_ipproto(in->ai_protocol);
out->ai_addrlen = get_bionic_len(in->ai_addr);
out->ai_addr = nullptr;
if (out->ai_addrlen) {
out->ai_addr = (bionic::sockaddr *) malloc(out->ai_addrlen);
from_host(in->ai_addr, out->ai_addr);
try {
out->ai_flags = from_host_ai_flags(in->ai_flags);
out->ai_family = from_host_af_family(in->ai_family);
out->ai_socktype = from_host_socktype(in->ai_socktype);
out->ai_protocol = from_host_ipproto(in->ai_protocol);
out->ai_addrlen = get_bionic_len(in->ai_addr);
out->ai_addr = nullptr;
if (out->ai_addrlen) {
out->ai_addr = (bionic::sockaddr *) malloc(out->ai_addrlen);
from_host(in->ai_addr, out->ai_addr);
}
out->ai_canonname = in->ai_canonname ? strdup(in->ai_canonname) : nullptr;

out->ai_next = from_host_alloc(in->ai_next);
return out;
}
catch (...) {
delete out;
//TODO Log errors
return from_host_alloc(in->ai_next);
}
out->ai_canonname = in->ai_canonname ? strdup(in->ai_canonname) : nullptr;

out->ai_next = from_host_alloc(in->ai_next);
return out;
}

void bionic::free_bionic_list(bionic::addrinfo *list) {
Expand Down

0 comments on commit b1514ae

Please sign in to comment.