From 06ee9e13db03a02b343a5d44cae3c4a5da48bf8a Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Fri, 14 Jun 2019 12:53:15 +0530 Subject: clang-scan: resolve warning dht-common.c: because there was a 'goto err' before assigning the 'local' variable, there is possibility of NULL dereference. As the check which was done wouldn't ever be true, removed the check. glusterd-geo-rep.c: a possible path where 'slave_host' could be NULL when it gets passed to strcmp() is found. strcmp() expects a valid string. Add a NULL check. Updates: bz#1622665 Change-Id: I64c280bc1beac9a2b109e8fa88f2a5ce8b823c3a Signed-off-by: Amar Tumballi --- xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'xlators/mgmt') diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index 74275c60711..3bbc7dca20e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -3435,6 +3435,12 @@ glusterd_op_stage_gsync_create(dict_t *dict, char **op_errstr) goto out; } + /* There is a remote possibility that slave_host can be NULL when + control reaches here. Add a check so we wouldn't crash in next + line */ + if (!slave_host) + goto out; + /* Now, check whether session is already started.If so, warn!*/ is_different_slavehost = (strcmp(slave_host, slave1.old_slvhost) != 0) ? _gf_true -- cgit