Richard
Joined: 02 Nov 2020 Posts: 1
|
Posted: Mon Nov 02, 2020 10:18 am Post subject: GetExternalIPAddress() Bug in 2.1.20200510 |
|
|
Code: |
struct in_addr addr; // <= Initialize with default value
if(use_ext_ip_addr)
{
strncpy(ext_ip_addr, use_ext_ip_addr, INET_ADDRSTRLEN);
ext_ip_addr[INET_ADDRSTRLEN - 1] = '\0';
// If I use use_ext_ip_addr, ext_ip_addr will have valid value here
}
else if(getifaddr(ext_if_name, ext_ip_addr, INET_ADDRSTRLEN, &addr, NULL) < 0)
{
syslog(LOG_ERR, "Failed to get ip address for interface %s",
ext_if_name);
strncpy(ext_ip_addr, "0.0.0.0", INET_ADDRSTRLEN);
}
// Since the value of addr_is_reserved() is 'addr ' which is not initialized if I use use_ext_ip_addr, my ext_ip_addr will be overwritten with 0.0.0.0 in below statements
if (addr_is_reserved(&addr))
strncpy(ext_ip_addr, "0.0.0.0", INET_ADDRSTRLEN);
// ....
// This causes GetExternalIPAddress() always returns "Action Failed"
// if I use use_ext_ip_addr
if (strcmp(ext_ip_addr, "0.0.0.0") == 0)
{
SoapError(h, 501, "Action Failed");
return;
}
|
|
|