From b834320d168feb54cf62bb1c0ae5af6f2704385e Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 4 Aug 2009 18:14:30 +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/src/posix.c') diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 0581bb7d8..4c707accf 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -3519,6 +3519,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