Skip to contentSkip to conversation

erofs-utils: error out if de_namelen is 0

PATCH In review Gao Xiang 2 participants 2 messages Jun 6, 2023 – Jun 7, 2023 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: error out if de_namelen is 0

de_namelen 0 is invalid for now.

Fixes 564adb0a852b ("erofs-utils: lib: add API to iterate dirs in EROFS")
---
 lib/dir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dir.c +1 -1
index cb8c188..abbf27a 100644
@@ -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;
Signature · 1 line
2.24.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Gao Xiang

de_namelen 0 is invalid for now.

Fixes 564adb0a852b ("erofs-utils: lib: add API to iterate dirs in EROFS")
---
  lib/dir.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/dir.c +0 -0
index cb8c188..abbf27a 100644

lib/dir.c static int traverse_dirents(struct erofs_dir_context *ctx, · line 47

Quoted 8 lines
lib/dir.c +1 -1
@@ -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;

Looks reasonable to me.

Signature · 2 lines
Best regards
Guo Xuenan