mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-06 01:40:28 +00:00
getaddrinfo AI_PASSIVE memory error
when getaddrinfo is passed name = NULL and AI_PASSIVE in hints->ai_flags, it was setting the s_addr value to INADDR_ANY but *not* returning the addrinfo pointer via *res = ai. This caused a free(NULL) memory error when the caller tried to free res, because the caller expects res to be a valid pointer to an struct addrinfo. Fix was to assign *res = ai before returning in the AI_PASSIVE case.
This commit is contained in:
parent
5cc93d31f8
commit
93146199fd
1 changed files with 1 additions and 0 deletions
|
@ -59,6 +59,7 @@ int getaddrinfo(const char *name, const char *service,
|
||||||
(hints && (hints->ai_flags & AI_PASSIVE) == AI_PASSIVE)
|
(hints && (hints->ai_flags & AI_PASSIVE) == AI_PASSIVE)
|
||||||
? INADDR_ANY
|
? INADDR_ANY
|
||||||
: INADDR_LOOPBACK;
|
: INADDR_LOOPBACK;
|
||||||
|
*res = ai;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (inet_pton(AF_INET, name, &ai->ai_addr4->sin_addr.s_addr) == 1) {
|
if (inet_pton(AF_INET, name, &ai->ai_addr4->sin_addr.s_addr) == 1) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue