From 1b60cc5fa1328c2287c7429aa44084e126434597 Mon Sep 17 00:00:00 2001 From: spidyy19 Date: Tue, 22 Sep 2026 12:16:26 +0530 Subject: [PATCH] fix(IPAddress): remove redundant condition in fromString6 --- api/IPAddress.cpp | 2 +- test/src/IPAddress/test_fromString6.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/IPAddress.cpp b/api/IPAddress.cpp index 05b41bc1..cc0b0eef 100644 --- a/api/IPAddress.cpp +++ b/api/IPAddress.cpp @@ -201,7 +201,7 @@ bool IPAddress::fromString6(const char *address) { // :: allowed once return false; } - if (*address != '\0' && *(address + 1) == ':') { + if (*(address + 1) == ':') { // ::: not allowed return false; } diff --git a/test/src/IPAddress/test_fromString6.cpp b/test/src/IPAddress/test_fromString6.cpp index bb9f01b0..76f285c9 100644 --- a/test/src/IPAddress/test_fromString6.cpp +++ b/test/src/IPAddress/test_fromString6.cpp @@ -382,11 +382,13 @@ TEST_CASE ("Extract invalid IPv6 address", "[IPAddress-fromString-12]") arduino::IPAddress ip; REQUIRE(ip.fromString(":::") == false); // three colons by self + REQUIRE(ip.fromString("::::") == false); // four colons by self REQUIRE(ip.fromString("::3:4:5:6::") == false); // two compressions REQUIRE(ip.fromString("2001:db8:102:10304:506:708:90a:b0c") == false); // 5 character field REQUIRE(ip.fromString("200x:db8:102:304:506:708:90a:b0c") == false); // invalid character REQUIRE(ip.fromString("2001:db8:102:304::506:708:90a:b0c") == false); // double colon with 8 other fields (so not a compression) REQUIRE(ip.fromString("2001:db8:102:304:::708:90a:b0c") == false); // three colons in middle + REQUIRE(ip.fromString("2001:db8:102:304::::708:90a:b0c") == false); // four colons in middle REQUIRE(ip.fromString("2001:db8:102:304:506:708:90a:b0c:d0e") == false); // 9 fields REQUIRE(ip.fromString("2001:db8:102:304:506:708:90a:") == false); // missing last group (but has a colon) REQUIRE(ip.fromString("2001:db8:102:304:506:708:90a") == false); // only seven groups