TITLE: System::isLoopBack() doest not handle all allowed IPv4 loopback addresses
DESCRIPTION: System::isLoopBack() is modified to check all allowed IPv4 loopback addresses
#define PEGASUS_IPV4_LOOPBACK_INIT 0x7F000001
#endif
+#define PEGASUS_IPV4_LOOPBACK_RANGE_START 0x7F000000
+#define PEGASUS_IPV4_LOOPBACK_RANGE_END 0x7FFFFFFF
+
+
#ifdef PEGASUS_ENABLE_IPV6
#define PEGASUS_IN6_ADDR_SIZE (sizeof (struct in6_addr))
#else
#ifdef PEGASUS_ENABLE_IPV6
struct in6_addr ip6 = PEGASUS_IPV6_LOOPBACK_INIT;
#endif
- Uint32 ip4 = PEGASUS_IPV4_LOOPBACK_INIT;
switch (af)
{
#ifdef PEGASUS_ENABLE_IPV6
Uint32 tmp;
memcpy(&tmp, binIPAddress, sizeof(Uint32));
Uint32 n = ntohl(tmp);
- return !memcmp(&ip4, &n, sizeof (ip4));
+ return n >= PEGASUS_IPV4_LOOPBACK_RANGE_START &&
+ n <= PEGASUS_IPV4_LOOPBACK_RANGE_END;
}
}
"127.0.0.1", binAddr) == 1);
PEGASUS_TEST_ASSERT(System::isLoopBack(HostAddress::AT_IPV4, binAddr));
+ PEGASUS_TEST_ASSERT(HostAddress::convertTextToBinary(HostAddress::AT_IPV4,
+ "127.0.0.8", binAddr) == 1);
+ PEGASUS_TEST_ASSERT(System::isLoopBack(HostAddress::AT_IPV4, binAddr));
+
+ PEGASUS_TEST_ASSERT(HostAddress::convertTextToBinary(HostAddress::AT_IPV4,
+ "127.10.120.18", binAddr) == 1);
+ PEGASUS_TEST_ASSERT(System::isLoopBack(HostAddress::AT_IPV4, binAddr));
+
+ PEGASUS_TEST_ASSERT(HostAddress::convertTextToBinary(HostAddress::AT_IPV4,
+ "127.255.255.255", binAddr) == 1);
+ PEGASUS_TEST_ASSERT(System::isLoopBack(HostAddress::AT_IPV4, binAddr));
+
+ PEGASUS_TEST_ASSERT(HostAddress::convertTextToBinary(HostAddress::AT_IPV4,
+ "127.0.0.0", binAddr) == 1);
+ PEGASUS_TEST_ASSERT(System::isLoopBack(HostAddress::AT_IPV4, binAddr));
PEGASUS_TEST_ASSERT(HostAddress::convertTextToBinary(HostAddress::AT_IPV6,
"::1", binAddr) == 1);
#ifdef PEGASUS_ENABLE_IPV6
struct in6_addr ip6 = PEGASUS_IPV6_LOOPBACK_INIT;
#endif
- uint32 ip4 = PEGASUS_IPV4_LOOPBACK_INIT;
if (!addr)
{
return FALSE;
case AF_INET:
{
uint32 n = ntohl( *(uint32*)addr);
- return !memcmp(&ip4, &n, sizeof (ip4));
+ return n >= PEGASUS_IPV4_LOOPBACK_RANGE_START &&
+ n <= PEGASUS_IPV4_LOOPBACK_RANGE_END;
}
}
#define PEGASUS_IPV4_LOOPBACK_INIT 0x7F000001
#endif
+#define PEGASUS_IPV4_LOOPBACK_RANGE_START 0x7F000000
+#define PEGASUS_IPV4_LOOPBACK_RANGE_END 0x7FFFFFFF
+
#ifdef PEGASUS_ENABLE_IPV6
#define PEGASUS_IN6_ADDR_SIZE (sizeof (struct in6_addr))
#else