This commit is contained in:
William Skellenger 2024-05-28 19:05:52 -04:00 committed by GitHub
commit a14721ca5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -96,7 +96,7 @@ ip6addr_aton(const char *cp, ip6_addr_t *addr)
break;
#endif /* LWIP_IPV4 */
} else if (!lwip_isxdigit(*s)) {
break;
return 0;
}
}
@ -166,7 +166,7 @@ ip6addr_aton(const char *cp, ip6_addr_t *addr)
(u32_t)(10 + (lwip_islower(*s) ? *s - 'a' : *s - 'A')));
} else {
/* unexpected digit, space? CRLF? */
break;
return 0;
}
}

View File

@ -198,6 +198,8 @@ START_TEST(test_ip6_aton_ipv4mapped)
const ip_addr_t addr_expected = IPADDR6_INIT_HOST(0, 0, 0xFFFF, 0xD4CC65D2);
const char *full_ipv6_addr = "0:0:0:0:0:FFFF:D4CC:65D2";
const char *shortened_ipv6_addr = "::FFFF:D4CC:65D2";
const char *shortened_ipv6_addr_unexpected_char = "::FFFF:D4CC:65DZ";
const char *shortened_ipv6_addr_invalid = "::GGGGGGGG";
const char *full_ipv4_mapped_addr = "0:0:0:0:0:FFFF:212.204.101.210";
const char *shortened_ipv4_mapped_addr = "::FFFF:212.204.101.210";
const char *bogus_ipv4_mapped_addr = "::FFFF:212.204.101.2101";
@ -223,6 +225,16 @@ START_TEST(test_ip6_aton_ipv4mapped)
fail_unless(ret == 1);
fail_unless(memcmp(&addr, &addr_expected, 16) == 0);
/* check shortened IPv6 with unexpected char */
memset(&addr6, 0, sizeof(addr6));
ret = ip6addr_aton(shortened_ipv6_addr_unexpected_char, &addr6);
fail_unless(ret == 0);
/* check shortened IPv6 that is clearly invalid */
memset(&addr6, 0, sizeof(addr6));
ret = ip6addr_aton(shortened_ipv6_addr_invalid, &addr6);
fail_unless(ret == 0);
/* checked shortened mixed representation */
memset(&addr6, 0, sizeof(addr6));
ret = ip6addr_aton(shortened_ipv4_mapped_addr, &addr6);