From a38f9cb7a6c9a25ceef9a0638add39dfd2b0c0d9 Mon Sep 17 00:00:00 2001 From: Sunny Kumar Date: Wed, 29 Aug 2018 01:39:28 +0530 Subject: glusterd : fix some coverity issues in glusterd-syncop.c This patch fixes CID 1382344, 1124655 and 1325537. Change-Id: I2412d6b88483e32a5de1baebb3823a985b2dcfb0 updates: bz#789278 Signed-off-by: Sunny Kumar --- xlators/mgmt/glusterd/src/glusterd-syncop.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c index 01a88f8e145..4c608ddca70 100644 --- a/xlators/mgmt/glusterd/src/glusterd-syncop.c +++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c @@ -96,7 +96,9 @@ gd_collate_errors (struct syncargs *args, int op_ret, int op_errno, break; } } - op_err[len] = '\0'; + + if (len > 0) + op_err[len] = '\0'; if (args->errstr) { len = snprintf (err_str, sizeof(err_str) - 1, @@ -1022,7 +1024,7 @@ out: errno = args.op_errno; if (args.dict) dict_unref (args.dict); - if (args.op_ret && (*errstr == NULL)) { + if (args.op_ret && errstr && (*errstr == NULL)) { if (op == GD_OP_HEAL_VOLUME) { gf_asprintf (errstr, "Glusterd Syncop Mgmt brick op '%s' failed." @@ -1576,7 +1578,7 @@ gd_unlock_op_phase (glusterd_conf_t *conf, glusterd_op_t op, int *op_ret, } else { ret = dict_get_int32 (op_ctx, "hold_global_locks", &global); - if (global) + if (!ret && global) type = "global"; else type = "vol"; -- cgit