diff options
author | Rich Felker <dalias@aerifal.cx> | 2022-10-20 19:48:32 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2022-10-20 19:48:32 -0400 |
commit | 8f9259450aa43a6fd539e428e61e2961b725fbae (patch) | |
tree | 3e43cbb56606528a955933c14231e743ff513bb5 /src | |
parent | 63402be229facae2d0de9c5943a6ed25246fd021 (diff) | |
download | musl-8f9259450aa43a6fd539e428e61e2961b725fbae.tar.gz musl-8f9259450aa43a6fd539e428e61e2961b725fbae.tar.xz musl-8f9259450aa43a6fd539e428e61e2961b725fbae.zip |
fix return value of gethostby{name[2],addr} with no result but no error
commit f081d5336a80b68d3e1bed789cc373c5c3d6699b fixed gethostbyname[2]_r to treat negative results as a non-error, leaving gethostbyname[2] wrongly returning a pointer to the unfilled result buffer rather than a null pointer. since, as documented with commit fe82bb9b921be34370e6b71a1c6f062c20999ae0, the caller of gethostby{name[2],addr}_r can always rely on the result pointer being set, use that consistently rather than trying to duplicate logic about whether we have a result or not in gethostby{name[2],addr}.
Diffstat (limited to 'src')
-rw-r--r-- | src/network/gethostbyaddr.c | 2 | ||||
-rw-r--r-- | src/network/gethostbyname2.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/network/gethostbyaddr.c b/src/network/gethostbyaddr.c index 598e2241..c3cacaac 100644 --- a/src/network/gethostbyaddr.c +++ b/src/network/gethostbyaddr.c @@ -20,5 +20,5 @@ struct hostent *gethostbyaddr(const void *a, socklen_t l, int af) err = gethostbyaddr_r(a, l, af, h, (void *)(h+1), size-sizeof *h, &res, &h_errno); } while (err == ERANGE); - return err ? 0 : h; + return res; } diff --git a/src/network/gethostbyname2.c b/src/network/gethostbyname2.c index dc9d6621..bd0da7f8 100644 --- a/src/network/gethostbyname2.c +++ b/src/network/gethostbyname2.c @@ -21,5 +21,5 @@ struct hostent *gethostbyname2(const char *name, int af) err = gethostbyname2_r(name, af, h, (void *)(h+1), size-sizeof *h, &res, &h_errno); } while (err == ERANGE); - return err ? 0 : h; + return res; } |