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

Guo Xuenan guoxuenan at huaweicloud.com
Wed Jun 7 21:37:41 AEST 2023


On 2023/6/6 15:51, Gao Xiang wrote:
> 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;

Looks reasonable to me.

Reviewed-by: Guo Xuenan <guoxuenan at huaweicloud.com>

-- 
Best regards
Guo Xuenan



More information about the Linux-erofs mailing list