From 91b3e5eeb45fbae3e9dbcf351d449feb14b98500 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 18 Oct 2017 22:37:21 +0200 Subject: [PATCH] inetd: Fix possible tcp socket leaks, found by Coverity Scan Signed-off-by: Joachim Nilsson --- src/inetd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/inetd.c b/src/inetd.c index e1dc1b53..fcbc7de2 100644 --- a/src/inetd.c +++ b/src/inetd.c @@ -155,13 +155,16 @@ static void socket_cb(uev_t *w, void *arg, int events) */ if (fcntl(stdin, F_SETFL, fcntl(stdin, F_GETFL, 0) & ~O_NONBLOCK) < 0) { logit(LOG_CRIT, "Failed disabling non-blocking on %s socket", svc->cmd); + if (svc->inetd.type == SOCK_STREAM) + close(stdin); return; } task = svc_new(svc->cmd, svc->inetd.next_id++, SVC_TYPE_INETD_CONN); if (!task) { - logit(LOG_CRIT, "%s: Unable to allocate service for inetd client", - svc->cmd); + logit(LOG_CRIT, "%s: Unable to allocate service for inetd client", svc->cmd); + if (svc->inetd.type == SOCK_STREAM) + close(stdin); return; }