From aaf483185e6fdd1b0102ee2ae27e53826efdfc21 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 4 Aug 2009 18:15:45 +0000 Subject: add check for making sure 'fd' belongs to directory in posix-readdir The root cause of this error is not found yet. But this check will make sure that there is no crash when the situation happens. Segfault can happen when a readdir() call comes over file's fd. Signed-off-by: Anand V. Avati BUG: 192 (sefault in posix-readdir) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=192 --- xlators/storage/posix/src/posix.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'xlators/storage/posix') diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 1772fc3ad..4bcea07f9 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -3536,6 +3536,13 @@ posix_readdir (call_frame_t *frame, xlator_t *this, goto out; } pfd = (struct posix_fd *)(long)tmp_pfd; + if (!pfd->path) { + op_errno = EBADFD; + gf_log (this->name, GF_LOG_DEBUG, + "pfd does not have path set (possibly file " + "fd, fd=%p)", fd); + goto out; + } real_path = pfd->path; real_path_len = strlen (real_path); -- cgit