From dbcece81ea8ce61cf452b18f7f91b24e74893784 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Mon, 15 Jun 2015 23:55:14 +0200 Subject: [PATCH] Fix Coverty CID #96210: Argument cannot be negative. We must check the return value from `accept()`, it may fail. Also, we should probably retry the syscall in some cases ... Signed-off-by: Joachim Nilsson --- api.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api.c b/api.c index fc102ad3..33805afe 100644 --- a/api.c +++ b/api.c @@ -126,9 +126,15 @@ static int do_query_inetd(char *buf, size_t len) static void cb(uev_t *w, void *UNUSED(arg), int UNUSED(events)) { - int sd = accept(w->fd, NULL, NULL); + int sd; struct init_request rq; + sd = accept(w->fd, NULL, NULL); + if (sd < 0) { + _pe("Failed serving API request"); + return; + } + while (1) { int result = 0; ssize_t len;