summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2019-04-11 16:56:32 +1000
committerKarolin Seeger <kseeger@samba.org>2019-05-17 07:18:29 +0000
commit08e229df43ed62991ea966e42e966afcacb4cb55 (patch)
tree7135c393298626bd27df00a417f5ac8aa1977c81 /ctdb
parent7db0d1a7646d6662df0e44cabad90d021e300305 (diff)
downloadsamba-08e229df43ed62991ea966e42e966afcacb4cb55.tar.gz
ctdb-tools: Fix ctdb dumpmemory to avoid printing trailing NUL
Fix ctdb rddumpmemory too. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13923 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> (cherry picked from commit f78d9388fb459dc83fafb4da6e683e3137ad40e1)
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/tools/ctdb.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 352881a62fe..71a14d67cb0 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -2434,8 +2434,8 @@ static int control_dumpmemory(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
return ret;
}
- n = write(1, mem_str, strlen(mem_str)+1);
- if (n < 0 || n != strlen(mem_str)+1) {
+ n = write(1, mem_str, strlen(mem_str));
+ if (n < 0 || n != strlen(mem_str)) {
fprintf(stderr, "Failed to write talloc summary\n");
return 1;
}
@@ -2446,10 +2446,12 @@ static int control_dumpmemory(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
static void dump_memory(uint64_t srvid, TDB_DATA data, void *private_data)
{
bool *done = (bool *)private_data;
+ size_t len;
ssize_t n;
- n = write(1, data.dptr, data.dsize);
- if (n < 0 || n != data.dsize) {
+ len = strnlen((const char *)data.dptr, data.dsize);
+ n = write(1, data.dptr, len);
+ if (n < 0 || n != len) {
fprintf(stderr, "Failed to write talloc summary\n");
}