From 3d0ef562640d6dfb8da10653ba2fec3ebcb98cf3 Mon Sep 17 00:00:00 2001 From: Eugene Ostroukhov Date: Mon, 19 Jun 2017 10:37:27 -0700 Subject: [PATCH] inspector, test: Fix test bug detected by Coverity Error value was not checked. Turns out, uv_ip6_addr was actually called on malformed IP (square brackets should not have been included). PR-URL: https://github.com/nodejs/node/pull/13799 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/cctest/test_inspector_socket_server.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/cctest/test_inspector_socket_server.cc b/test/cctest/test_inspector_socket_server.cc index cd9e8f1cfcbb89..a8c3bcd2f7f5d5 100644 --- a/test/cctest/test_inspector_socket_server.cc +++ b/test/cctest/test_inspector_socket_server.cc @@ -172,12 +172,14 @@ class SocketWrapper { contents_.clear(); uv_tcp_init(loop_, &socket_); union {sockaddr generic; sockaddr_in v4; sockaddr_in6 v6;} addr; + int err = 0; if (v6) { - uv_ip6_addr(host.c_str(), port, &addr.v6); + err = uv_ip6_addr(host.c_str(), port, &addr.v6); } else { - uv_ip4_addr(host.c_str(), port, &addr.v4); + err = uv_ip4_addr(host.c_str(), port, &addr.v4); } - int err = uv_tcp_connect(&connect_, &socket_, &addr.generic, Connected_); + ASSERT_EQ(0, err); + err = uv_tcp_connect(&connect_, &socket_, &addr.generic, Connected_); ASSERT_EQ(0, err); SPIN_WHILE(!connected_) uv_read_start(reinterpret_cast(&socket_), AllocCallback, @@ -618,7 +620,7 @@ TEST_F(InspectorSocketServerTest, BindsToIpV6) { ASSERT_TRUE(server->Start()); SocketWrapper socket1(&loop); - socket1.Connect("[::]", server.port(), true); + socket1.Connect("::", server.port(), true); socket1.Write(WsHandshakeRequest(MAIN_TARGET_ID)); socket1.Expect(WS_HANDSHAKE_RESPONSE); server->Stop(ServerHolder::CloseCallback);