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

Fix more potential null-ptr-derefs in use of gethostbyname()

No known sightings of these sites actually being the location of a segfault,
but as we learned from the segfaults in rblchk(), the first entry in the
h_addr_list can be NULL in some cases.
parent 1f7cd77a
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4419 passed
......@@ -3024,7 +3024,8 @@ static void ctrl_thread(void* arg)
ip_addr=0;
/* TODO: IPv6 this here lookup */
if(startup->options&FTP_OPT_LOOKUP_PASV_IP
&& (host=gethostbyname(server_host_name()))!=NULL)
&& (host=gethostbyname(server_host_name()))!=NULL
&& host->h_addr_list[0] != NULL)
ip_addr=ntohl(*((ulong*)host->h_addr_list[0]));
if(ip_addr==0 && (ip_addr=startup->pasv_ip_addr.s_addr)==0)
ip_addr=ntohl(pasv_addr.in.sin_addr.s_addr);
......
......@@ -943,6 +943,9 @@ static u_long resolve_ip(const char *inaddr)
if((host=gethostbyname(inaddr))==NULL)
return((u_long)INADDR_NONE);
if(host->h_addr_list[0] == NULL)
return (u_long)INADDR_NONE;
return(*((ulong*)host->h_addr_list[0]));
}
......
......@@ -381,6 +381,8 @@ u_long resolve_ip(char *addr)
return(inet_addr(addr));
if((host=gethostbyname(addr))==NULL)
return((u_long)INADDR_NONE);
if(host->h_addr_list[0] == NULL)
return (u_long)INADDR_NONE;
return(*((ulong*)host->h_addr_list[0]));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment