From 8a2f2d07702f83b4f170f7cb4789536921f22bf0 Mon Sep 17 00:00:00 2001 From: Martin Pärtel Date: Tue, 3 Jul 2012 11:18:33 +0300 Subject: Fail readdir() if pathconf fails. --- src/bindfs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bindfs.c b/src/bindfs.c index 48b732c..ce22825 100644 --- a/src/bindfs.c +++ b/src/bindfs.c @@ -401,10 +401,14 @@ static int bindfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, struct stat st; int result = 0; long pc_ret; - + pc_ret = pathconf(path, _PC_NAME_MAX); - if (pc_ret < 0) - pc_ret = NAME_MAX; /* or scream and abort()? */ + if (pc_ret < 0) { + DPRINTF("pathconf failed: %s (%d)", strerror(errno), errno); + /* Could use NAME_MAX but it may not be safe if the underlying + * FS is NFS or similar. */ + return -errno; + } de_buf = malloc(offsetof(struct dirent, d_name) + pc_ret + 1); seekdir(dp, offset); -- cgit v1.2.3