From 3b0d3efe40686ec93298ad296e087753109e28f5 Mon Sep 17 00:00:00 2001 From: szaka Date: Wed, 8 Aug 2007 16:15:15 +0000 Subject: [PATCH] fix ntfs_readdir(): return with error if filldir() fails --- libntfs-3g/dir.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/libntfs-3g/dir.c b/libntfs-3g/dir.c index eefcb520..52fcb66b 100644 --- a/libntfs-3g/dir.c +++ b/libntfs-3g/dir.c @@ -724,7 +724,7 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos, le16_to_cpu(dir_ni->mrec->sequence_number)), NTFS_DT_DIR); if (rc) - goto done; + goto err_out; ++*pos; } if (*pos == 1) { @@ -739,7 +739,7 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos, rc = filldir(dirent, dotdot, 2, FILE_NAME_POSIX, *pos, parent_mref, NTFS_DT_DIR); if (rc) - goto done; + goto err_out; ++*pos; } @@ -816,7 +816,7 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos, if (rc) { ntfs_attr_put_search_ctx(ctx); ctx = NULL; - goto done; + goto err_out; } } ntfs_attr_put_search_ctx(ctx); @@ -965,7 +965,7 @@ find_next_index_buffer: rc = ntfs_filldir(dir_ni, pos, index_vcn_size_bits, INDEX_TYPE_ALLOCATION, ia, ie, dirent, filldir); if (rc) - goto done; + goto err_out; } goto find_next_index_buffer; EOD: @@ -978,13 +978,7 @@ done: ntfs_attr_close(bmp_na); if (ia_na) ntfs_attr_close(ia_na); -#ifdef DEBUG - if (!rc) - ntfs_log_debug("EOD, *pos 0x%llx, returning 0.\n", (long long)*pos); - else - ntfs_log_debug("filldir returned %i, *pos 0x%llx, returning 0.\n", - rc, (long long)*pos); -#endif + ntfs_log_debug("EOD, *pos 0x%llx, returning 0.\n", (long long)*pos); return 0; dir_err_out: errno = EIO;