Skip to contentSkip to conversation

erofs-utils: tar: guard empty PAX path trimming

PATCH New Vansh Choudhary 1 participant 1 message Mar 26 Library code

lore
Share & tools
lore
#0 lore raw

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.

---
 lib/tar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tar.c +1 -1
index 77754fd..24e0413 100644
@@ -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