diff options
-rw-r--r-- | lib/libfuse/fuse_ops.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/libfuse/fuse_ops.c b/lib/libfuse/fuse_ops.c index 8ec2543b9c6..4f7800922a8 100644 --- a/lib/libfuse/fuse_ops.c +++ b/lib/libfuse/fuse_ops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_ops.c,v 1.13 2013/10/08 04:57:39 guenther Exp $ */ +/* $OpenBSD: fuse_ops.c,v 1.14 2013/11/21 22:03:26 syl Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -276,9 +276,7 @@ ifuse_ops_readdir(struct fuse *f, struct fusebuf *fbuf) size = fbuf->fb_io_len; startsave = 0; - fbuf->fb_dat = malloc(FUSEBUFMAXSIZE); - bzero(fbuf->fb_dat, FUSEBUFMAXSIZE); - + fbuf->fb_dat = malloc(size); vn = tree_get(&f->vnode_tree, fbuf->fb_ino); if (!vn->fd->filled) { @@ -313,6 +311,9 @@ ifuse_ops_readdir(struct fuse *f, struct fusebuf *fbuf) vn->fd->filled = 1; } + if (fbuf->fb_len == 0) + free(fbuf->fb_dat); + return (0); } @@ -427,6 +428,9 @@ ifuse_ops_read(struct fuse *f, struct fusebuf *fbuf) else fbuf->fb_err = ret; + if (fbuf->fb_len == 0) + free(fbuf->fb_dat); + return (0); } @@ -557,15 +561,10 @@ ifuse_ops_readlink(struct fuse *f, struct fusebuf *fbuf) ret = -ENOSYS; free(realname); - if (!ret) - len = strnlen(name, PATH_MAX); - else - len = -1; - - fbuf->fb_len = len + 1; fbuf->fb_err = ret; - if (!ret) { + len = strnlen(name, PATH_MAX); + fbuf->fb_len = len + 1; fbuf->fb_dat = malloc(fbuf->fb_len); memcpy(fbuf->fb_dat, name, len); fbuf->fb_dat[len] = '\0'; |