You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.0 KiB

From f3db0c99faf813e0f2e9ffcf599416555a59df1f Mon Sep 17 00:00:00 2001
From: Ashish Pandey <aspandey@redhat.com>
Date: Tue, 9 Feb 2021 16:43:35 +0530
Subject: [PATCH 542/542] xlaotrs/mgmt: Fixing coverity issue 1445996
Backport of https://github.com/gluster/glusterfs/pull/2148/commits/9785e96e0bdf6e60896570fdf5e4a6976a6f60ba
Fixing "Null pointer dereferences"
BUG: 1927235
Change-Id: Idbc014e1302d2450f97bccd028681198c0d97424
Signed-off-by: Ashish Pandey <aspandey@redhat.com>
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/237433
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
xlators/mgmt/glusterd/src/glusterd-volgen.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index a242b5c..71aed08 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -2916,21 +2916,23 @@ validate_user_xlator_position(dict_t *this, char *key, data_t *value,
{
int ret = -1;
int i = 0;
+ char *value_str = NULL;
if (!value)
goto out;
+ value_str = data_to_str(value);
+ if (!value_str)
+ goto out;
+
if (fnmatch("user.xlator.*.*", key, 0) == 0) {
ret = 0;
goto out;
}
- char *value_str = data_to_str(value);
- if (!value_str)
- goto out;
-
int num_xlators = sizeof(server_graph_table) /
sizeof(server_graph_table[0]);
+
for (i = 0; i < num_xlators; i++) {
if (server_graph_table[i].dbg_key &&
strcmp(value_str, server_graph_table[i].dbg_key) == 0) {
@@ -2942,7 +2944,7 @@ validate_user_xlator_position(dict_t *this, char *key, data_t *value,
out:
if (ret == -1)
gf_log("glusterd", GF_LOG_ERROR, "invalid user xlator position %s = %s",
- key, value->data);
+ key, value_str);
return ret;
}
--
1.8.3.1