From 4704270443a67aadd963da480a189757b1e98d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20A=C3=A7acak?= <110401522+huseyinacacak-janea@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:44:19 +0300 Subject: [PATCH] src: fix IsIPAddress for IPv6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the bug when copying IPv6 host to a variable to remove brackets. Fixes: https://github.com/nodejs/node/issues/47427 PR-URL: https://github.com/nodejs/node/pull/53400 Reviewed-By: Tobias Nießen Reviewed-By: Richard Lau --- 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;