From fcb114502d01a49e5be27bbdb87b00137839f069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Mon, 19 Apr 2010 11:04:13 +0200 Subject: [PATCH] fixed an error checking when extending a file list in lowntfs-3g --- src/lowntfs-3g.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c index e87654f1..9249b969 100644 --- a/src/lowntfs-3g.c +++ b/src/lowntfs-3g.c @@ -1033,21 +1033,32 @@ static int ntfs_fuse_filler(ntfs_fuse_fill_context_t *fill_ctx, newone = (ntfs_fuse_fill_item_t*)ntfs_malloc (sizeof(ntfs_fuse_fill_item_t) + current->bufsize); - newone->off = 0; - newone->bufsize = current->bufsize; - newone->next = (ntfs_fuse_fill_item_t*)NULL; - current->next = newone; - fill_ctx->last = newone; - current = newone; - sz = fuse_add_direntry(fill_ctx->req, current->buf, - current->bufsize - current->off, - filename, &st, current->off); + if (newone) { + newone->off = 0; + newone->bufsize = current->bufsize; + newone->next = (ntfs_fuse_fill_item_t*)NULL; + current->next = newone; + fill_ctx->last = newone; + current = newone; + sz = fuse_add_direntry(fill_ctx->req, + current->buf, + current->bufsize - current->off, + filename, &st, current->off); + if (!sz) { + errno = EIO; + ntfs_log_error("Could not add a" + " directory entry (inode %lld)\n", + (unsigned long long)MREF(mref)); + } + } else { + sz = 0; + errno = ENOMEM; + } } if (sz) { current->off += sz; } else { ret = -1; - errno = EIO; /* ? */ } }