From d05d4c61e784d08e87aed5b924504004f53b4fad Mon Sep 17 00:00:00 2001 From: Sunny Kumar Date: Tue, 17 Jul 2018 15:56:35 +0530 Subject: geo-rep : fix possible crash Problem : In 'glusterd_verify_slave' while tokenizing error message we call 'strtok_r' and store return value in 'tmp' which can be NULL. We are passing this 'tmp' as 1st argument to 'strcmp' which will lead to segmentation fault. Solution : before calling 'strcmp' we should NULL check 'tmp'. Change-Id: Ifd3864b904afe6cd09d9e5a4b55c6d0578e22b9d fixes: bz#1602121 Signed-off-by: Sunny Kumar --- xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index 6761277be05..8dc20ffc954 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -2799,14 +2799,17 @@ glusterd_verify_slave (char *volname, char *slave_url, char *slave_vol, /* Tokenize the error message from gverify.sh to figure out * if the error is a force blocker or not. */ tmp = strtok_r (buf, "|", &save_ptr); + if (!tmp) { + ret = -1; + goto out; + } if (!strcmp (tmp, "FORCE_BLOCKER")) *is_force_blocker = 1; else { /* No FORCE_BLOCKER flag present so all that is * present is the error message. */ *is_force_blocker = 0; - if (tmp) - *op_errstr = gf_strdup (tmp); + *op_errstr = gf_strdup (tmp); ret = -1; goto out; } -- cgit