Skip to content
Snippets Groups Projects
Commit f8c65bcf authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Fixup the copy-pasted resolve_ip() with same fixes from main.cpp/mailsrvr.c

Don't null-deref h_addr_list.
Return in_addr_t instead of u_long.
parent a47f94b8
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
......@@ -881,22 +881,24 @@ BOOL wait_for_call(COM_HANDLE com_handle)
/****************************************************************************/
/****************************************************************************/
u_long resolve_ip(const char *addr)
in_addr_t resolve_ip(const char *addr)
{
HOSTENT* host;
const char* p;
if(*addr==0)
return((u_long)INADDR_NONE);
return INADDR_NONE;
for(p=addr;*p;p++)
if(*p!='.' && !isdigit(*p))
break;
if(!(*p))
return(inet_addr(addr));
if((host=gethostbyname(addr))==NULL)
return((u_long)INADDR_NONE);
return(*((ulong*)host->h_addr_list[0]));
if((host=gethostbyname(addr))==NULL)
return INADDR_NONE;
if(host->h_addr_list == NULL)
return INADDR_NONE;
return *((in_addr_t*)host->h_addr_list[0]);
}
/****************************************************************************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment