From 37b4c63829df529f0c14c1f82e4deb9f14aeefda Mon Sep 17 00:00:00 2001 From: cha0smaster Date: Tue, 19 Jul 2005 21:22:24 +0000 Subject: [PATCH] ntfsmount: * Fix bug in inside ntfs_fuse_filler, it's sometimes allocated to small buffer. (Thanks to Rich for finding this bug) * Fix bug in error handling of ntfs_fuse_readdir. ARGH, why we already had release? --- ntfsprogs/ntfsmount.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/ntfsprogs/ntfsmount.c b/ntfsprogs/ntfsmount.c index 659f6424..4d154bf9 100644 --- a/ntfsprogs/ntfsmount.c +++ b/ntfsprogs/ntfsmount.c @@ -303,23 +303,16 @@ static int ntfs_fuse_filler(ntfs_fuse_fill_context_t *fill_ctx, const s64 pos __attribute__((unused)), const MFT_REF mref, const unsigned dt_type __attribute__((unused))) { - char *filename; - int err = 0; + char *filename = NULL; if (name_type == FILE_NAME_DOS) return 0; - filename = malloc(name_len + 1); - if (!filename) + if (ntfs_ucstombs(name, name_len, &filename, 0) < 0) return -errno; - if (ntfs_ucstombs(name, name_len, &filename, name_len + 1) < 0) { - err = -errno; - free(filename); - return err; - } if (MREF(mref) >= FILE_first_user || ctx->show_sys_files) fill_ctx->filler(fill_ctx->buf, filename, NULL, 0); free(filename); - return err; + return 0; } static int ntfs_fuse_readdir(const char *path, void *buf, @@ -330,6 +323,7 @@ static int ntfs_fuse_readdir(const char *path, void *buf, ntfs_volume *vol; ntfs_inode *ni; s64 pos = 0; + int err = 0; vol = ctx->vol; fill_ctx.filler = filler; @@ -337,9 +331,11 @@ static int ntfs_fuse_readdir(const char *path, void *buf, ni = ntfs_pathname_to_inode(vol, NULL, path); if (!ni) return -errno; - ntfs_readdir(ni, &pos, &fill_ctx, (ntfs_filldir_t)ntfs_fuse_filler); + if (ntfs_readdir(ni, &pos, &fill_ctx, + (ntfs_filldir_t)ntfs_fuse_filler)) + err = -errno; ntfs_inode_close(ni); - return 0; + return err; } static int ntfs_fuse_open(const char *org_path,