[PATCH] A few cleanups

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Oct 13 19:08:01 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 062c9b7b3b069d7dad0eed1081bf4a0f3cddee3a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 12 Oct 2015 16:52:49 +0200
Subject: [PATCH 1/5] ctdbd: Fix a typo

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

diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index 1165318..e945d51 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -1276,7 +1276,7 @@ static int update_local_flags(struct ctdb_recoverd *rec, struct ctdb_node_map *n
 }
 
 
-/* Create a new random generation ip. 
+/* Create a new random generation id.
    The generation id can not be the INVALID_GENERATION id
 */
 static uint32_t new_generation(void)
-- 
1.9.1


From 63d09d0d227ea9f62a37a819b84b2b9aaddbb5f6 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 12 Oct 2015 22:10:51 +0200
Subject: [PATCH 2/5] libdap: Fix a '\0' vs NULL mixup

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

diff --git a/libcli/ldap/ldap_message.c b/libcli/ldap/ldap_message.c
index 0c664b7..bf83627 100644
--- a/libcli/ldap/ldap_message.c
+++ b/libcli/ldap/ldap_message.c
@@ -762,7 +762,7 @@ static struct ldb_val **ldap_decode_substring(TALLOC_CTX *mem_ctx, struct ldb_va
 	}
 	chunks[chunk_num]->length = strlen(value);
 
-	chunks[chunk_num + 1] = '\0';
+	chunks[chunk_num + 1] = NULL;
 
 	return chunks;
 }
-- 
1.9.1


From 98dd909de07b0a6e46847dda3d399534222ad0e4 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 13 Oct 2015 20:34:24 +0200
Subject: [PATCH 3/5] lib: Fix CID 1327227 Uninitialized scalar variable

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/lib/dbwrap/dbwrap_ctdb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index e024fe5..9066beb 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -852,7 +852,7 @@ static NTSTATUS db_ctdb_store(struct db_record *rec, TDB_DATA data, int flag)
 
 static NTSTATUS db_ctdb_send_schedule_for_deletion(struct db_record *rec)
 {
-	NTSTATUS status;
+	NTSTATUS status = NT_STATUS_OK;
 	int ret;
 	struct ctdb_control_schedule_for_deletion *dd;
 	TDB_DATA indata;
@@ -888,6 +888,8 @@ static NTSTATUS db_ctdb_send_schedule_for_deletion(struct db_record *rec)
 			  "SCHEDULE_FOR_DELETION: %s, cstatus = %d\n",
 			  strerror(ret), cstatus));
 		if (ret != 0) {
+			status = map_nt_error_from_unix(ret);
+		} else {
 			status = NT_STATUS_UNSUCCESSFUL;
 		}
 	}
-- 
1.9.1


From 4a17c4795ee6f2f52e2c56b8e7c7243f63dfdc6a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 13 Oct 2015 20:40:54 +0200
Subject: [PATCH 4/5] ctdb: Fix CID 1327224 Unbounded source buffer

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 ctdb/tests/src/comm_client_test.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ctdb/tests/src/comm_client_test.c b/ctdb/tests/src/comm_client_test.c
index d3f5f9e..e1ebe1c 100644
--- a/ctdb/tests/src/comm_client_test.c
+++ b/ctdb/tests/src/comm_client_test.c
@@ -157,10 +157,13 @@ static int socket_init(char *sockpath)
 {
 	struct sockaddr_un addr;
 	int fd, ret;
+	size_t len;
 
 	memset(&addr, 0, sizeof(addr));
 	addr.sun_family = AF_UNIX;
-	strcpy(addr.sun_path, sockpath);
+
+	len = strlcpy(addr.sun_path, sockpath, sizeof(addr.sun_path));
+	assert(len < sizeof(addr.sun_path));
 
 	fd = socket(AF_UNIX, SOCK_STREAM, 0);
 	assert(fd != -1);
-- 
1.9.1


From 7a3d3de1af9e8933e008034795f1237e5a1f974b Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 13 Oct 2015 20:42:06 +0200
Subject: [PATCH 5/5] ctdb: Fix CID 1327223 Unbounded source buffer

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 ctdb/tests/src/comm_server_test.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ctdb/tests/src/comm_server_test.c b/ctdb/tests/src/comm_server_test.c
index fe0fffd..7a7656f 100644
--- a/ctdb/tests/src/comm_server_test.c
+++ b/ctdb/tests/src/comm_server_test.c
@@ -313,10 +313,13 @@ static int socket_init(char *sockpath)
 {
 	struct sockaddr_un addr;
 	int fd, ret;
+	size_t len;
 
 	memset(&addr, 0, sizeof(addr));
 	addr.sun_family = AF_UNIX;
-	strcpy(addr.sun_path, sockpath);
+
+	len = strlcpy(addr.sun_path, sockpath, sizeof(addr.sun_path));
+	assert(len < sizeof(addr.sun_path));
 
 	fd = socket(AF_UNIX, SOCK_STREAM, 0);
 	assert(fd != -1);
-- 
1.9.1



More information about the samba-technical mailing list