mirror of
https://git.musl-libc.org/git/musl
synced 2025-01-21 21:52:04 +03:00
fix return value of gethostby{name[2],addr} with no result but no error
commitf081d5336a
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 commitfe82bb9b92
, 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}.
This commit is contained in:
parent
63402be229
commit
8f9259450a
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user