do not check empty string with strlen(s) == 0

see #292
This commit is contained in:
Thomas Bernard 2018-06-01 10:55:45 +02:00
parent 72005ce86a
commit ef179a45e3
2 changed files with 6 additions and 6 deletions

View File

@ -380,7 +380,7 @@ OpenAndConfHTTPSocket(unsigned short * port)
#if defined(SO_BINDTODEVICE) && !defined(MULTIPLE_EXTERNAL_IP)
/* One and only one LAN interface */
if(lan_addrs.lh_first != NULL && lan_addrs.lh_first->list.le_next == NULL
&& strlen(lan_addrs.lh_first->ifname) > 0)
&& lan_addrs.lh_first->ifname[0] != '\0')
{
if(setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE,
lan_addrs.lh_first->ifname,

View File

@ -410,7 +410,7 @@ AddPortMapping(struct upnphttp * h, const char * action, const char * ns)
r_host = GetValueFromNameValueList(&data, "NewRemoteHost");
#ifndef SUPPORT_REMOTEHOST
#ifdef UPNP_STRICT
if (r_host && (strlen(r_host) > 0) && (0 != strcmp(r_host, "*")))
if (r_host && (r_host[0] != '\0') && (0 != strcmp(r_host, "*")))
{
ClearNameValueList(&data);
SoapError(h, 726, "RemoteHostOnlySupportsWildcard");
@ -606,7 +606,7 @@ AddAnyPortMapping(struct upnphttp * h, const char * action, const char * ns)
}
#ifndef SUPPORT_REMOTEHOST
#ifdef UPNP_STRICT
if (r_host && (strlen(r_host) > 0) && (0 != strcmp(r_host, "*")))
if (r_host && (r_host[0] != '\0') && (0 != strcmp(r_host, "*")))
{
ClearNameValueList(&data);
SoapError(h, 726, "RemoteHostOnlySupportsWildcard");
@ -724,7 +724,7 @@ GetSpecificPortMappingEntry(struct upnphttp * h, const char * action, const char
}
#ifndef SUPPORT_REMOTEHOST
#ifdef UPNP_STRICT
if (r_host && (strlen(r_host) > 0) && (0 != strcmp(r_host, "*")))
if (r_host && (r_host[0] != '\0') && (0 != strcmp(r_host, "*")))
{
ClearNameValueList(&data);
SoapError(h, 726, "RemoteHostOnlySupportsWildcard");
@ -813,7 +813,7 @@ DeletePortMapping(struct upnphttp * h, const char * action, const char * ns)
}
#ifndef SUPPORT_REMOTEHOST
#ifdef UPNP_STRICT
if (r_host && (strlen(r_host) > 0) && (0 != strcmp(r_host, "*")))
if (r_host && (r_host[0] != '\0') && (0 != strcmp(r_host, "*")))
{
ClearNameValueList(&data);
SoapError(h, 726, "RemoteHostOnlySupportsWildcard");
@ -1618,7 +1618,7 @@ AddPinhole(struct upnphttp * h, const char * action, const char * ns)
* - InternalClient value equals to the control point's IP address.
* It is REQUIRED that InternalClient cannot be one of IPv6
* addresses used by the gateway. */
if(!int_ip || 0 == strlen(int_ip) || 0 == strcmp(int_ip, "*"))
if(!int_ip || int_ip[0] == '\0' || 0 == strcmp(int_ip, "*"))
{
SoapError(h, 708, "WildCardNotPermittedInSrcIP");
goto clear_and_exit;