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