Merge "Fix inet_aton on LP32."
This commit is contained in:
commit
1ab3f303d2
@ -39,8 +39,9 @@ int inet_aton(const char* cp, in_addr* addr) {
|
|||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < 4; ++i) {
|
for (i = 0; i < 4; ++i) {
|
||||||
char* end;
|
char* end;
|
||||||
|
errno = 0;
|
||||||
parts[i] = strtoul(cp, &end, 0);
|
parts[i] = strtoul(cp, &end, 0);
|
||||||
if (end == cp || (*end != '.' && *end != '\0')) return 0;
|
if (errno != 0 || end == cp || (*end != '.' && *end != '\0')) return 0;
|
||||||
if (*end == '\0') break;
|
if (*end == '\0') break;
|
||||||
cp = end + 1;
|
cp = end + 1;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,11 @@ TEST(arpa_inet, inet_aton_invalid) {
|
|||||||
// Out of range a form.
|
// Out of range a form.
|
||||||
ASSERT_EQ(0, inet_aton("0x100000000", nullptr));
|
ASSERT_EQ(0, inet_aton("0x100000000", nullptr));
|
||||||
|
|
||||||
ASSERT_EQ(0, inet_aton("0400.0.0.1", nullptr)); // Out of range octal.
|
// 64-bit overflow.
|
||||||
|
ASSERT_EQ(0, inet_aton("0x10000000000000000", nullptr));
|
||||||
|
|
||||||
|
// Out of range octal.
|
||||||
|
ASSERT_EQ(0, inet_aton("0400.0.0.1", nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(arpa_inet, inet_lnaof) {
|
TEST(arpa_inet, inet_lnaof) {
|
||||||
|
Loading…
Reference in New Issue
Block a user