inet_pton() instead of inet_addr()

This commit is contained in:
Thomas Bernard 2020-10-17 15:19:58 +02:00
parent 69fc376929
commit 7a66f373fc
2 changed files with 10 additions and 4 deletions

View File

@ -52,11 +52,14 @@ static const struct { uint32_t address; uint32_t rmask; } reserved[] = {
*/
int addr_is_reserved(const char * addr_str)
{
unsigned long addr_n;
uint32_t address;
uint32_t addr_n, address;
size_t i;
addr_n = inet_addr(addr_str);
/* was : addr_n = inet_addr(addr_str); */
if (inet_pton(AF_INET, addr_str, &addr_n) < 0) {
/* error */
return 0;
}
if (addr_n == INADDR_NONE)
return 1;

View File

@ -720,7 +720,10 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
#if defined(_WIN32) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
InetPtonA(AF_INET, multicastif, &mc_if);
#else
mc_if.s_addr = inet_addr(multicastif); /* ex: 192.168.x.x */
/* was : mc_if.s_addr = inet_addr(multicastif); */ /* ex: 192.168.x.x */
if (inet_pton(AF_INET, multicastif, &mc_if.s_addr) < 0) {
mc_if.s_addr = INADDR_NONE;
}
#endif
if(mc_if.s_addr != INADDR_NONE)
{