diff options
author | nik-redhat <nladha@redhat.com> | 2020-09-25 18:39:51 +0530 |
---|---|---|
committer | MOHIT AGRAWAL <moagrawa@redhat.com> | 2020-09-29 14:32:09 +0000 |
commit | 773aaddc656a57b23bfae60808f099439329602c (patch) | |
tree | 8b22cd1060c3e7348a4eb3f2029e80684a41e460 | |
parent | 748d7fe9cb7d20192b4b7d826509127fa04f43fb (diff) | |
download | glusterfs-773aaddc656a57b23bfae60808f099439329602c.tar.gz glusterfs-773aaddc656a57b23bfae60808f099439329602c.tar.xz glusterfs-773aaddc656a57b23bfae60808f099439329602c.zip |
dht: explicit null dereference
Added a null check for uuid_list_copy, to avoid
null dereference in strtok_r() in case of strdup()
failure.
CID: 1325612
CID: 1274223
Updates: #1060
Change-Id: I641a5068cd76d7b2ed92eccf39e7f97d6f7b2480
Signed-off-by: nik-redhat <nladha@redhat.com>
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 2 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-shared.c | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 42e143e3a5..aa3f938e9b 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -4314,6 +4314,8 @@ dht_find_local_subvol_cbk(call_frame_t *frame, void *cookie, xlator_t *this, index = conf->local_subvols_cnt; uuid_list_copy = gf_strdup(uuid_list); + if (!uuid_list_copy) + goto unlock; for (uuid_str = strtok_r(uuid_list, " ", &saveptr); uuid_str; uuid_str = next_uuid_str) { diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c index 96caf40d0b..f46c44cca5 100644 --- a/xlators/cluster/dht/src/dht-shared.c +++ b/xlators/cluster/dht/src/dht-shared.c @@ -537,6 +537,8 @@ gf_defrag_pattern_list_fill(xlator_t *this, gf_defrag_info_t *defrag, pattern_str = strtok_r(data, ",", &tmp_str); while (pattern_str) { dup_str = gf_strdup(pattern_str); + if (!dup_str) + goto out; pattern_list = GF_CALLOC(1, sizeof(gf_defrag_pattern_list_t), 1); if (!pattern_list) { goto out; |