d2787b
From 76c9faf5c750428e5eb69462b82ee0c12cbdabc0 Mon Sep 17 00:00:00 2001
d2787b
From: nik-redhat <nladha@redhat.com>
d2787b
Date: Fri, 25 Sep 2020 18:39:51 +0530
d2787b
Subject: [PATCH 593/610] dht: explicit null dereference
d2787b
d2787b
Added a null check for uuid_list_copy, to avoid
d2787b
null dereference in strtok_r() in case of strdup()
d2787b
failure.
d2787b
d2787b
CID: 1325612
d2787b
CID: 1274223
d2787b
d2787b
>Updates: #1060
d2787b
d2787b
>Change-Id: I641a5068cd76d7b2ed92eccf39e7f97d6f7b2480
d2787b
>Signed-off-by: nik-redhat <nladha@redhat.com>
d2787b
d2787b
Upstream link: https://review.gluster.org/c/glusterfs/+/25046
d2787b
BUG: 1997447
d2787b
d2787b
Change-Id: I576b4ce610948bdb84eb30377a684c54df718bdc
d2787b
Signed-off-by: nik-redhat <nladha@redhat.com>
d2787b
Reviewed-on: https://code.engineering.redhat.com/gerrit/c/rhs-glusterfs/+/280063
d2787b
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d2787b
---
d2787b
 xlators/cluster/dht/src/dht-common.c | 2 ++
d2787b
 xlators/cluster/dht/src/dht-shared.c | 2 ++
d2787b
 2 files changed, 4 insertions(+)
d2787b
d2787b
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
d2787b
index edfc6e7..e6a16ff 100644
d2787b
--- a/xlators/cluster/dht/src/dht-common.c
d2787b
+++ b/xlators/cluster/dht/src/dht-common.c
d2787b
@@ -4296,6 +4296,8 @@ dht_find_local_subvol_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
d2787b
         index = conf->local_subvols_cnt;
d2787b
 
d2787b
         uuid_list_copy = gf_strdup(uuid_list);
d2787b
+        if (!uuid_list_copy)
d2787b
+            goto unlock;
d2787b
 
d2787b
         for (uuid_str = strtok_r(uuid_list, " ", &saveptr); uuid_str;
d2787b
              uuid_str = next_uuid_str) {
d2787b
diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c
d2787b
index 58e3339..cca272a 100644
d2787b
--- a/xlators/cluster/dht/src/dht-shared.c
d2787b
+++ b/xlators/cluster/dht/src/dht-shared.c
d2787b
@@ -567,6 +567,8 @@ gf_defrag_pattern_list_fill(xlator_t *this, gf_defrag_info_t *defrag,
d2787b
     pattern_str = strtok_r(data, ",", &tmp_str);
d2787b
     while (pattern_str) {
d2787b
         dup_str = gf_strdup(pattern_str);
d2787b
+        if (!dup_str)
d2787b
+            goto out;
d2787b
         pattern_list = GF_CALLOC(1, sizeof(gf_defrag_pattern_list_t), 1);
d2787b
         if (!pattern_list) {
d2787b
             goto out;
d2787b
-- 
d2787b
1.8.3.1
d2787b