Commit 5cd081a3 authored by Pekka Pessi's avatar Pekka Pessi

bnf.c: host_cmp() does not depend on inet_pton() not accepting non-canonic IP addresses anymore.

darcs-hash:20061120222232-65a35-32cde3303a01247e171044f1e1226a3e62b9383e.gz
parent 617b569a
......@@ -824,6 +824,7 @@ static size_t convert_ip_address(char const *s,
size_t *return_addrlen)
{
size_t len;
int canonize;
#if SU_HAVE_IN6
char buf[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
......@@ -855,8 +856,13 @@ static size_t convert_ip_address(char const *s,
}
#endif
len = span_ip4_address(s);
len = span_canonic_ip4_address(s, &canonize);
if (len) {
if (canonize) {
char *tmp = buf;
s = memcpy(tmp, s, len + 1);
scan_ip4_address(&tmp);
}
if (s[len] == '\0' && inet_pton(AF_INET, s, addr) == 1)
return (void)(*return_addrlen = 4), len;
else
......
......@@ -319,7 +319,7 @@ int host_test(void)
TEST(host_has_domain_invalid("1-.invalid."), 0);
/* Invalid IP4 addresses (extra leading zeros) */
TEST_1(host_cmp("127.0.0.1", "127.0.0.01"));
TEST_1(!host_cmp("127.0.0.1", "127.0.0.01"));
TEST_1(!host_cmp("[ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255]",
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
/* Invalid reference (extra leading zeros) */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment