[PATCH] erofs-utils: tar: guard slash-only header names
Vansh Choudhary
ch at vnsh.in
Tue Mar 31 04:34:46 AEDT 2026
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 {
*_path = '\0';
- while (path[j - 1] == '/')
+ while (j && path[j - 1] == '/')
path[--j] = '\0';
}
}
--
2.43.0
More information about the Linux-erofs
mailing list