From: Daniel Wagner <[email protected]>

When connect() fails we should close the socket.

Reported by coverity.
---
 tools/dnsproxy-test.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/dnsproxy-test.c b/tools/dnsproxy-test.c
index 84602b6..ad707f3 100644
--- a/tools/dnsproxy-test.c
+++ b/tools/dnsproxy-test.c
@@ -147,6 +147,9 @@ static int connect_tcp_socket(char *server)
 
        if (sk >= 0 && connect(sk, rp->ai_addr, rp->ai_addrlen) < 0) {
                err = -errno;
+               close(sk);
+               sk = 0;
+
                fprintf(stderr, "Failed to connect to DNS server at %s "
                                "errno %d/%s\n",
                        server, -err, strerror(-err));
-- 
1.7.10.207.g0bb2e

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to