diff --git a/src/url.cpp b/src/url.cpp index c4e1c487e..32d81fd8c 100644 --- a/src/url.cpp +++ b/src/url.cpp @@ -65,7 +65,7 @@ bool url::parse_ipv4(std::string_view input) { // We have the last value. // At this stage, ipv4 contains digit_count*8 bits. // So we have 32-digit_count*8 bits left. - if (segment_result > (uint64_t(1) << (32 - digit_count * 8))) { + if (segment_result >= (uint64_t(1) << (32 - digit_count * 8))) { return is_valid = false; } ipv4 <<= (32 - digit_count * 8); diff --git a/src/url_aggregator.cpp b/src/url_aggregator.cpp index 2b761ad34..e9a3a1546 100644 --- a/src/url_aggregator.cpp +++ b/src/url_aggregator.cpp @@ -898,7 +898,7 @@ bool url_aggregator::parse_ipv4(std::string_view input) { // We have the last value. // At this stage, ipv4 contains digit_count*8 bits. // So we have 32-digit_count*8 bits left. - if (segment_result > (uint64_t(1) << (32 - digit_count * 8))) { + if (segment_result >= (uint64_t(1) << (32 - digit_count * 8))) { return is_valid = false; } ipv4 <<= (32 - digit_count * 8); diff --git a/tests/basic_tests.cpp b/tests/basic_tests.cpp index 7a3bd8a42..4f44badc8 100644 --- a/tests/basic_tests.cpp +++ b/tests/basic_tests.cpp @@ -396,3 +396,9 @@ TYPED_TEST(basic_tests, nodejs_50235) { ASSERT_EQ(out->get_href(), "http://test.com:5/path?param=1"); SUCCEED(); } + +// https://github.com/nodejs/node/issues/51514 +TYPED_TEST(basic_tests, nodejs_51514) { + auto out = ada::parse("http://1.1.1.256"); + ASSERT_FALSE(out); +}