[PATCH] erofs-utils: tar: guard slash-only header names

Yifan Zhao stopire at gmail.com
Tue Mar 31 14:58:45 AEDT 2026


On 3/31/2026 1:34 AM, Vansh Choudhary wrote:
> Check that the assembled header path is non-empty before trimming
> trailing slashes from it.
>
> A malformed tar header name made up only of '/' characters could
> otherwise drive the trim loop to read before the start of the buffer.
>
> Signed-off-by: Vansh Choudhary <ch at vnsh.in>
> ---
>   lib/tar.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/tar.c b/lib/tar.c
> index 4e97522..39e2321 100644
> --- a/lib/tar.c
> +++ b/lib/tar.c
> @@ -866,7 +866,7 @@ out_eot:
>   			path[1] = '\0';
>   		} else {
I think this else branch has ensured `j != 0`.
>   			*_path = '\0';
> -			while (path[j - 1] == '/')
> +			while (j && path[j - 1] == '/')
>   				path[--j] = '\0';
>   		}
>   	}


More information about the Linux-erofs mailing list