erofs-utils: lib/tar: skip PAX entries with empty path
PATCH 1/1 erofs-utils: lib/tar: skip PAX entries with empty path
When a PAX extended header contains 'path=' with an empty value, the computed length becomes zero. The subsequent trailing-slash removal loop accesses eh->path[j - 1] where j is zero, resulting in an out-of-bounds read and undefined behavior.
Skip such entries to avoid unsafe pointer arithmetic and invalid filename handling.
Signed-off-by Utkal Singh <[email protected]>
--- lib/tar.c | 2 ++ 1 file changed, 2 insertions(+)
lib/tar.c +2 -0
@@ -510,6 +510,8 @@ int tarerofs_parse_pax_header(struct erofs_iostream *ios,if (!strncmp (kv,"path=" ,sizeof ("path=" ) -1 )) {int j = p -1 - value; +if (!j) +continue ;free (eh->path); eh->path =strdup (value);while (eh->path[j -1 ] =='/' )
Signature · 1 line
2.43.0