From 1a9df097463d41679b87b6cbd4634fc3390fe82c Mon Sep 17 00:00:00 2001 From: arao Date: Tue, 17 Feb 2015 16:53:14 +0530 Subject: dht: Fixing dereference after null check CID: 1223229 The 'loc' ptr is not checked before dereferencing, which is handled. Change-Id: Icf668150bde190e6f1b9f58a038099338516efe8 BUG: 789278 Signed-off-by: arao Reviewed-on: http://review.gluster.org/9666 Tested-by: Gluster Build System Reviewed-by: Raghavendra G Tested-by: Raghavendra G --- xlators/cluster/dht/src/dht-layout.c | 51 +++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 13 deletions(-) (limited to 'xlators/cluster/dht') diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c index 2ed15c5e43c..6ef28472307 100644 --- a/xlators/cluster/dht/src/dht-layout.c +++ b/xlators/cluster/dht/src/dht-layout.c @@ -745,9 +745,12 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol, } if (pos == -1) { - gf_msg_debug (this->name, 0, - "%s - no layout info for subvolume %s", - loc->path, subvol->name); + if (loc) { + gf_msg_debug (this->name, 0, + "%s - no layout info for subvolume %s", + loc ? loc->path : "path not found", + subvol->name); + } ret = 1; goto out; } @@ -756,9 +759,15 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol, if (!xattr) { if (err == 0) { - gf_log (this->name, GF_LOG_INFO, - "%s: xattr dictionary is NULL", - loc->path); + if (loc) { + gf_log (this->name, GF_LOG_INFO, + "%s: xattr dictionary is NULL", + loc->path); + } else { + gf_log (this->name, GF_LOG_INFO, + "path not found: " + "xattr dictionary is NULL"); + } ret = -1; } goto out; @@ -769,9 +778,16 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol, if (dict_ret < 0) { if (err == 0 && layout->list[pos].stop) { - gf_log (this->name, GF_LOG_INFO, - "%s: Disk layout missing, gfid = %s", - loc->path, gfid); + if (loc) { + gf_log (this->name, GF_LOG_INFO, + "%s: Disk layout missing, gfid = %s", + loc->path, gfid); + } else { + gf_log (this->name, GF_LOG_INFO, + "path not found: " + "Disk layout missing, gfid = %s", + gfid); + } ret = -1; } goto out; @@ -781,10 +797,19 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, xlator_t *subvol, count = ntoh32 (disk_layout[0]); if (count != 1) { - gf_msg (this->name, GF_LOG_ERROR, 0, - DHT_MSG_INVALID_DISK_LAYOUT, - "Invalid disk layout: invalid count %d," - "path = %s, gfid = %s ", count, loc->path, gfid); + if (loc) { + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_INVALID_DISK_LAYOUT, + "Invalid disk layout: invalid count %d," + "path = %s, gfid = %s ", + count, loc->path, gfid); + } else { + gf_msg (this->name, GF_LOG_ERROR, 0, + DHT_MSG_INVALID_DISK_LAYOUT, + "Invalid disk layout: invalid count %d," + "path not found, gfid = %s ", + count, gfid); + } ret = -1; goto out; } -- cgit