mirror of
https://git.musl-libc.org/git/musl
synced 2025-01-08 07:42:09 +03:00
fix gethostby*_r result pointer value on error
according to the documentation in the man pages, the GNU extension functions gethostbyaddr_r, gethostbyname_r and gethostbyname2_r are guaranteed to set the result pointer to NULL in case of error or no result.
This commit is contained in:
parent
2e5d256984
commit
fe82bb9b92
@ -18,6 +18,8 @@ int gethostbyaddr_r(const void *a, socklen_t l, int af,
|
|||||||
socklen_t sl = af==AF_INET6 ? sizeof sa.sin6 : sizeof sa.sin;
|
socklen_t sl = af==AF_INET6 ? sizeof sa.sin6 : sizeof sa.sin;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
*res = 0;
|
||||||
|
|
||||||
/* Load address argument into sockaddr structure */
|
/* Load address argument into sockaddr structure */
|
||||||
if (af==AF_INET6 && l==16) memcpy(&sa.sin6.sin6_addr, a, 16);
|
if (af==AF_INET6 && l==16) memcpy(&sa.sin6.sin6_addr, a, 16);
|
||||||
else if (af==AF_INET && l==4) memcpy(&sa.sin.sin_addr, a, 4);
|
else if (af==AF_INET && l==4) memcpy(&sa.sin.sin_addr, a, 4);
|
||||||
|
@ -17,6 +17,7 @@ int gethostbyname2_r(const char *name, int af,
|
|||||||
int i, cnt;
|
int i, cnt;
|
||||||
size_t align, need;
|
size_t align, need;
|
||||||
|
|
||||||
|
*res = 0;
|
||||||
cnt = __lookup_name(addrs, canon, name, af, AI_CANONNAME);
|
cnt = __lookup_name(addrs, canon, name, af, AI_CANONNAME);
|
||||||
if (cnt<0) switch (cnt) {
|
if (cnt<0) switch (cnt) {
|
||||||
case EAI_NONAME:
|
case EAI_NONAME:
|
||||||
|
Loading…
Reference in New Issue
Block a user