From d228fbfb68b67989a31e05cc84e54bb1fdea892e Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 8 Oct 2025 01:30:00 +0300 Subject: [PATCH] Fix ipv6 port parsing in addr_util --- src/util/addr_util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/addr_util.cpp b/src/util/addr_util.cpp index a829a2da..8f07b413 100644 --- a/src/util/addr_util.cpp +++ b/src/util/addr_util.cpp @@ -17,7 +17,7 @@ bool string_to_addr(std::string str, bool parse_port, int default_port, struct s if (parse_port) { int p = str.rfind(':'); - if (p != std::string::npos && !(str.length() > 0 && str[p-1] == ']')) // "[ipv6]" which contains ':' + if (p != std::string::npos && (str[0] != '[' || p > 0 && str[p-1] == ']')) // "[ipv6]" which contains ':' { char null_byte = 0; int scanned = sscanf(str.c_str()+p+1, "%d%c", &default_port, &null_byte);