mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:57:46 +00:00
LibC: getaddrinfo: Set addrinfo sin_port to 0 if service arg is NULL
This commit is contained in:
parent
bf1ef6533c
commit
ce010de74f
1 changed files with 11 additions and 4 deletions
|
@ -362,6 +362,9 @@ struct servent* getservent()
|
|||
|
||||
struct servent* getservbyname(const char* name, const char* protocol)
|
||||
{
|
||||
if (name == nullptr)
|
||||
return nullptr;
|
||||
|
||||
bool previous_file_open_setting = keep_service_file_open;
|
||||
setservent(1);
|
||||
struct servent* current_service = nullptr;
|
||||
|
@ -689,10 +692,14 @@ int getaddrinfo(const char* __restrict node, const char* __restrict service, con
|
|||
svc_ent = getservbyname(service, proto);
|
||||
}
|
||||
if (!svc_ent) {
|
||||
char* end;
|
||||
port = htons(strtol(service, &end, 10));
|
||||
if (*end)
|
||||
return EAI_FAIL;
|
||||
if (service) {
|
||||
char* end;
|
||||
port = htons(strtol(service, &end, 10));
|
||||
if (*end)
|
||||
return EAI_FAIL;
|
||||
} else {
|
||||
port = htons(0);
|
||||
}
|
||||
|
||||
if (hints && hints->ai_socktype != 0)
|
||||
socktype = hints->ai_socktype;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue