Skip to content

Commit

Permalink
fix: check segment result range on url_aggregator(for node issue #51514)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenKS12138 committed Jan 21, 2024
1 parent 54b6cb9 commit ef554d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/url_aggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/basic_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,6 @@ TYPED_TEST(basic_tests, nodejs_50235) {

// https://github.com/nodejs/node/issues/51514
TYPED_TEST(basic_tests, nodejs_51514) {
auto out = ada::parse<ada::url>("http://1.1.1.256");
auto out = ada::parse<TypeParam>("http://1.1.1.256");
ASSERT_FALSE(out);
}

0 comments on commit ef554d7

Please sign in to comment.