From 119b4e6371f20d20b74ba854d463f827de0609c2 Mon Sep 17 00:00:00 2001 From: rishubhjain Date: Mon, 8 Apr 2019 20:20:12 +0530 Subject: GlusterD:Checking for null value to void explicit dereferencing of null pointer Before calling strtok_r a check for null pointer is necessary to avoid dereferencing of null pointer CID:1398617 CID:1274074 Change-Id: I34956c6e04af1faa22d550e6474909ecd36f5d6c updates: bz#789278 Signed-off-by: rishubhjain --- xlators/mgmt/glusterd/src/glusterd-utils.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'xlators/mgmt') diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index e50db060aa1..626c9913d7a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -8458,6 +8458,10 @@ glusterd_set_dump_options(char *dumpoptions_path, char *options, int option_cnt) goto out; } dup_options = gf_strdup(options); + + if (!dup_options) { + goto out; + } gf_msg("glusterd", GF_LOG_INFO, 0, GD_MSG_STATEDUMP_OPTS_RCVD, "Received following statedump options: %s", dup_options); option = strtok_r(dup_options, " ", &tmpptr); @@ -8608,6 +8612,10 @@ glusterd_nfs_statedump(char *options, int option_cnt, char **op_errstr) GF_ASSERT(conf); dup_options = gf_strdup(options); + + if (!dup_options) { + goto out; + } option = strtok_r(dup_options, " ", &tmpptr); if (strcmp(option, conf->nfs_svc.name)) { snprintf(msg, sizeof(msg), @@ -8679,6 +8687,9 @@ glusterd_client_statedump(char *volname, char *options, int option_cnt, char *pid = NULL; dup_options = gf_strdup(options); + if (!dup_options) { + goto out; + } option = strtok_r(dup_options, " ", &tmpptr); if (strcmp(option, "client")) { snprintf(msg, sizeof(msg), @@ -8732,6 +8743,9 @@ glusterd_quotad_statedump(char *options, int option_cnt, char **op_errstr) GF_ASSERT(conf); dup_options = gf_strdup(options); + if (!dup_options) { + goto out; + } option = strtok_r(dup_options, " ", &tmpptr); if (strcmp(option, conf->quotad_svc.name)) { snprintf(msg, sizeof(msg), -- cgit