summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikas Gorur <vikas@gluster.com>2010-04-13 18:39:34 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-04-20 01:50:57 -0700
commit51f521ac9a140c147d22a2a38463984132a083a8 (patch)
tree242b857587653392020ed75dfdba5bfe9ca1843a
parent4b754a77545fb7db030471fd4d84b8eee6008d7c (diff)
cluster/afr: Fix possible NULL dereference in readdirp_cbk
Signed-off-by: Vikas Gorur <vikas@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 722 (Segfault in glusterfs 3.0.3 replicate/afr_readdirp_cbk) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=722
-rw-r--r--xlators/cluster/afr/src/afr-dir-read.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/xlators/cluster/afr/src/afr-dir-read.c b/xlators/cluster/afr/src/afr-dir-read.c
index 5af168bf04e..501cc3e8c58 100644
--- a/xlators/cluster/afr/src/afr-dir-read.c
+++ b/xlators/cluster/afr/src/afr-dir-read.c
@@ -513,7 +513,7 @@ afr_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int child_index = -1;
- uint64_t ctx = 0;
+ uint64_t ctx = 0;
afr_fd_ctx_t *fd_ctx = NULL;
off_t offset = 0;
@@ -559,20 +559,22 @@ afr_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
}
- list_for_each_entry_safe (entry, tmp, &entries->list, list) {
- inum = afr_itransform (entry->d_ino, priv->child_count,
- child_index);
- entry->d_ino = inum;
- inum = afr_itransform (entry->d_stat.ia_ino,
- priv->child_count, child_index);
- entry->d_stat.ia_ino = inum;
-
- if ((local->fd->inode == local->fd->inode->table->root)
- && !strcmp (entry->d_name, GF_REPLICATE_TRASH_DIR)) {
- list_del_init (&entry->list);
- FREE (entry);
- }
- }
+ if (op_ret != -1) {
+ list_for_each_entry_safe (entry, tmp, &entries->list, list) {
+ inum = afr_itransform (entry->d_ino, priv->child_count,
+ child_index);
+ entry->d_ino = inum;
+ inum = afr_itransform (entry->d_stat.ia_ino,
+ priv->child_count, child_index);
+ entry->d_stat.ia_ino = inum;
+
+ if ((local->fd->inode == local->fd->inode->table->root)
+ && !strcmp (entry->d_name, GF_REPLICATE_TRASH_DIR)) {
+ list_del_init (&entry->list);
+ FREE (entry);
+ }
+ }
+ }
if (priv->strict_readdir) {
if (fd_ctx->failed_over) {