[PATCH] erofs-utils: error out if de_namelen is 0

Gao Xiang hsiangkao at linux.alibaba.com
Tue Jun 6 17:51:25 AEST 2023


de_namelen 0 is invalid for now.

Fixes: 564adb0a852b ("erofs-utils: lib: add API to iterate dirs in EROFS")
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 lib/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/dir.c b/lib/dir.c
index cb8c188..abbf27a 100644
--- a/lib/dir.c
+++ b/lib/dir.c
@@ -41,7 +41,7 @@ static int traverse_dirents(struct erofs_dir_context *ctx,
 			break;
 		}
 
-		if (nameoff + de_namelen > maxsize ||
+		if (nameoff + de_namelen > maxsize || !de_namelen ||
 				de_namelen > EROFS_NAME_LEN) {
 			errmsg = "bogus dirent namelen";
 			break;
-- 
2.24.4



More information about the Linux-erofs mailing list