From ef554d74b6cd52db6027e2c06a959c987f1163fe Mon Sep 17 00:00:00 2001 From: ChenKS12138 Date: Sun, 21 Jan 2024 21:26:50 +0800 Subject: [PATCH] fix: check segment result range on url_aggregator(for node issue #51514) --- src/url_aggregator.cpp | 2 +- tests/basic_tests.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 c3cb1e417..4f44badc8 100644 --- a/tests/basic_tests.cpp +++ b/tests/basic_tests.cpp @@ -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("http://1.1.1.256"); + auto out = ada::parse("http://1.1.1.256"); ASSERT_FALSE(out); }