From 5d88111a142b3c37e92bdd36699a04fd054d27f4 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Wed, 22 May 2019 17:46:19 +0200 Subject: Fix some "Null pointer dereference" coverity issues This patch fixes the following CID's: * 1124829 * 1274075 * 1274083 * 1274128 * 1274135 * 1274141 * 1274143 * 1274197 * 1274205 * 1274210 * 1274211 * 1288801 * 1398629 Change-Id: Ia7c86cfab3245b20777ffa296e1a59748040f558 Updates: bz#789278 Signed-off-by: Xavi Hernandez --- xlators/cluster/dht/src/dht-shared.c | 4 ++++ xlators/cluster/dht/src/switch.c | 9 +++++++++ 2 files changed, 13 insertions(+) (limited to 'xlators/cluster') diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c index e5a2367598b..e4c9d5c3dec 100644 --- a/xlators/cluster/dht/src/dht-shared.c +++ b/xlators/cluster/dht/src/dht-shared.c @@ -277,6 +277,10 @@ dht_parse_decommissioned_bricks(xlator_t *this, dht_conf_t *conf, goto out; dup_brick = gf_strdup(bricks); + if (dup_brick == NULL) { + goto out; + } + node = strtok_r(dup_brick, ",", &tmpstr); while (node) { for (i = 0; i < conf->subvolume_cnt; i++) { diff --git a/xlators/cluster/dht/src/switch.c b/xlators/cluster/dht/src/switch.c index a782fcdfbd2..207d109a025 100644 --- a/xlators/cluster/dht/src/switch.c +++ b/xlators/cluster/dht/src/switch.c @@ -610,9 +610,15 @@ set_switch_pattern(xlator_t *this, dht_conf_t *conf, const char *pattern_str) /* Get the pattern for considering switch case. "option block-size *avi:10MB" etc */ option_string = gf_strdup(pattern_str); + if (option_string == NULL) { + goto err; + } switch_str = strtok_r(option_string, ";", &tmp_str); while (switch_str) { dup_str = gf_strdup(switch_str); + if (dup_str == NULL) { + goto err; + } switch_opt = GF_CALLOC(1, sizeof(struct switch_struct), gf_switch_mt_switch_struct); if (!switch_opt) { @@ -647,6 +653,9 @@ set_switch_pattern(xlator_t *this, dht_conf_t *conf, const char *pattern_str) if (childs) { dup_childs = gf_strdup(childs); + if (dup_childs == NULL) { + goto err; + } child = strtok_r(dup_childs, ",", &tmp); while (child) { if (gf_switch_valid_child(this, child)) { -- cgit