[PATCH] Coverity fixes

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Jun 16 00:25:02 MDT 2015


Hi, Stefan!

Attached find two coverity fixes. One is a no-brainer, and
the other one might need some thought. I think checking
return values is important ...

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 639fbbbf8d05f8c4fb29e4c5b1e443e96b7ae99b Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 16 Jun 2015 06:12:47 +0000
Subject: [PATCH 1/2] lib: Fix CID 1306764 Unchecked return value

tevent_req_oom exists right for this case :-)

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/async_req/async_sock.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c
index 03bda58..89272ee 100644
--- a/lib/async_req/async_sock.c
+++ b/lib/async_req/async_sock.c
@@ -267,7 +267,7 @@ struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 	}
 
 	if (!tevent_queue_add(queue, ev, req, writev_trigger, NULL)) {
-		tevent_req_nomem(NULL, req);
+		tevent_req_oom(req);
 		return tevent_req_post(req, ev);
 	}
 	return req;
-- 
1.7.9.5


From 88ed500dd43f9756facf06760881c3e93eea6f4c Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 16 Jun 2015 06:20:56 +0000
Subject: [PATCH 2/2] lib: Fix CID 1306765 Unchecked return value from library

This one might be a bit controversial. I don't see from man fcntl how this
could fail. But if it does, we definitely do want to know about it. And here we
don't have any good way to tell our caller, so abort.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/async_req/async_sock.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c
index 89272ee..e90f4e6 100644
--- a/lib/async_req/async_sock.c
+++ b/lib/async_req/async_sock.c
@@ -156,7 +156,13 @@ static void async_connect_cleanup(struct tevent_req *req,
 
 	TALLOC_FREE(state->fde);
 	if (state->fd != -1) {
-		fcntl(state->fd, F_SETFL, state->old_sockflags);
+		int ret;
+
+		ret = fcntl(state->fd, F_SETFL, state->old_sockflags);
+		if (ret == -1) {
+			abort();
+		}
+
 		state->fd = -1;
 	}
 }
-- 
1.7.9.5



More information about the samba-technical mailing list