[PATCH] Fix new Coverity findings
Volker Lendecke
Volker.Lendecke at SerNet.DE
Tue Oct 6 07:59:45 UTC 2015
Hi!
Review&push appreciated!
Thanks,
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 861ac433d1b31d1e4dbfa2913f8f20c3cc7ded69 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 6 Oct 2015 09:54:19 +0200
Subject: [PATCH 1/2] lib: Fix CID 1325733 Uninitialized scalar variable
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/ctdbd_conn.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index da2c3a9..c7a6e22 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -690,6 +690,7 @@ static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
if (hdr->operation != CTDB_REPLY_CONTROL) {
DEBUG(0, ("received invalid reply\n"));
+ status = NT_STATUS_INVALID_NETWORK_RESPONSE;
goto fail;
}
reply = (struct ctdb_reply_control *)hdr;
--
1.9.1
From fed33d342915f06477d3eeff48ae857430f9dbaa Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 6 Oct 2015 09:57:59 +0200
Subject: [PATCH 2/2] lib: Fix CID 1128553 Unchecked return value from library
At the same time, avoid chmod in favor of fchmod
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/dbwrap/dbwrap_ctdb.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 9852bc7..9402bdd 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1597,11 +1597,6 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
tdb_flags &= TDB_SEQNUM|TDB_VOLATILE|
TDB_MUTEX_LOCKING|TDB_CLEAR_IF_FIRST;
- /* honor permissions if user has specified O_CREAT */
- if (open_flags & O_CREAT) {
- chmod(db_path, mode);
- }
-
prio.db_id = db_ctdb->db_id;
prio.priority = lock_order;
@@ -1653,6 +1648,19 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
}
talloc_free(db_path);
+ /* honor permissions if user has specified O_CREAT */
+ if (open_flags & O_CREAT) {
+ int fd, ret;
+ fd = tdb_fd(db_ctdb->wtdb->tdb);
+ ret = fchmod(fd, mode);
+ if (ret == -1) {
+ DBG_WARNING("%s: fchmod failed: %s\n", __func__,
+ strerror(errno));
+ TALLOC_FREE(result);
+ return NULL;
+ }
+ }
+
if (result->persistent) {
db_ctdb->lock_ctx = g_lock_ctx_init(db_ctdb,
ctdb_conn_msg_ctx(conn));
--
1.9.1
More information about the samba-technical
mailing list