From 4901d9ddc8d8c33ecdca363dcb67e66482745fa5 Mon Sep 17 00:00:00 2001
From: nicm <nicm>
Date: Fri, 11 Oct 2013 08:07:12 +0000
Subject: [PATCH] Don't leak file descriptors in the rare MSG_VERSION case.
 From Chris Johnsen.

---
 server-client.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/server-client.c b/server-client.c
index 6aa2a0fa..b6d4870d 100644
--- a/server-client.c
+++ b/server-client.c
@@ -808,6 +808,8 @@ server_client_msg_dispatch(struct client *c)
 		if (imsg.hdr.peerid != PROTOCOL_VERSION) {
 			server_write_client(c, MSG_VERSION, NULL, 0);
 			c->flags |= CLIENT_BAD;
+			if (imsg.fd != -1)
+				close(imsg.fd);
 			imsg_free(&imsg);
 			continue;
 		}