Skip to contentSkip to conversation

erofs-utils: lib/tar: skip PAX entries with empty path

PATCH New Utkal Singh 1 participant 1 message Mar 15 Library code

lore
Share & tools
lore
#0 lore raw

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.

---
 lib/tar.c | 2 ++
 1 file changed, 2 insertions(+)
lib/tar.c +2 -0
index 26461f8..be86984 100644
@@ -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