erofs-utils: tar: guard empty PAX path trimming
PATCH 1/1 erofs-utils: tar: guard empty PAX path trimming
Avoid reading eh->path[j - 1] when a PAX path record carries an empty value.
Check that j is non-zero before trimming trailing slashes from the duplicated path buffer.
Signed-off-by Vansh Choudhary <[email protected]>
--- lib/tar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tar.c +1 -1
@@ -517,7 +517,7 @@ int tarerofs_parse_pax_header(struct erofs_iostream *ios,int j = p -1 - value;free (eh->path); eh->path =strdup (value); -while (eh->path[j -1 ] =='/' ) +while (j && eh->path[j -1 ] =='/' ) eh->path[--j] ='\0' ; }else if (!strncmp (kv,"linkpath=" ,sizeof ("linkpath=" ) -1 )) {
Signature · 1 line
2.43.0