From d279741e278ed5a3fe40429d017863b03fc0e3a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20A=C3=A7acak?= Date: Mon, 10 Jun 2024 09:51:42 +0300 Subject: [PATCH] src: fix IsIPAddress for IPv6 Fix the bug when copying IPv6 host to a variable to remove brackets. Fixes: https://github.com/nodejs/node/issues/47427 --- src/inspector_socket.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inspector_socket.cc b/src/inspector_socket.cc index c121579365055e..b6059b49410868 100644 --- a/src/inspector_socket.cc +++ b/src/inspector_socket.cc @@ -192,7 +192,7 @@ static bool IsIPAddress(const std::string& host) { // Parse the IPv6 address to ensure it is syntactically valid. char ipv6_str[INET6_ADDRSTRLEN]; std::copy(host.begin() + 1, host.end() - 1, ipv6_str); - ipv6_str[host.length()] = '\0'; + ipv6_str[host.length() - 2] = '\0'; unsigned char ipv6[sizeof(struct in6_addr)]; if (uv_inet_pton(AF_INET6, ipv6_str, ipv6) != 0) return false;