Patchwork [3/7] libext2fs: wrong loop will cause dir entry is not found in dirsearch command

login
register
mail settings
Submitter Zheng Liu
Date Nov. 15, 2012, 8:13 a.m.
Message ID <1352967209-29616-4-git-send-email-wenqing.lz@taobao.com>
Download mbox | patch
Permalink /patch/199208/
State New
Headers show

Comments

Zheng Liu - Nov. 15, 2012, 8:13 a.m.
From: Zheng Liu <wenqing.lz@taobao.com>

It needs to iterate dir entry until offset is greater than or equal to size of
inline data.  But currently it is only iterate until offset >= len (length of
name).

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
---
 lib/ext2fs/inline_data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/lib/ext2fs/inline_data.c b/lib/ext2fs/inline_data.c
index f0473fd..7f5ec3e 100644
--- a/lib/ext2fs/inline_data.c
+++ b/lib/ext2fs/inline_data.c
@@ -129,7 +129,7 @@  static int do_search_dir(ext2_filsys fs, void *start, int size,
 	unsigned rec_len;
 	errcode_t errcode;
 
-	while (offset < len) {
+	while (offset < size) {
 		de = (struct ext2_dir_entry *)(start + offset);
 		errcode = ext2fs_get_rec_len(fs, de, &rec_len);
 		if (errcode) {