[PATCH] erofs-utils: tar: guard empty PAX path trimming
Vansh Choudhary
ch at vnsh.in
Thu Mar 26 23:54:06 AEDT 2026
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 <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 77754fd..24e0413 100644
--- a/lib/tar.c
+++ b/lib/tar.c
@@ -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)) {
--
2.43.0
More information about the Linux-erofs
mailing list