[cpio] Fix calculation of name lengths in CPIO headers

Commit 12ea8c4 ("[cpio] Allow for construction of parent directories
as needed") introduced a regression in constructing CPIO archive
headers for relative paths (e.g. simple filenames with no leading
slash).

Fix by counting the number of path components rather than the number
of path separators, and add some test cases to cover CPIO header
construction.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-03-12 14:15:16 +00:00
parent 5f3ecbde5a
commit d6ee9a9242
3 changed files with 274 additions and 6 deletions

View File

@@ -89,3 +89,4 @@ REQUIRE_OBJECT ( editstring_test );
REQUIRE_OBJECT ( p256_test );
REQUIRE_OBJECT ( p384_test );
REQUIRE_OBJECT ( efi_siglist_test );
REQUIRE_OBJECT ( cpio_test );