]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[cpio] Fix calculation of name lengths in CPIO headers
authorMichael Brown <mcb30@ipxe.org>
Wed, 12 Mar 2025 14:15:16 +0000 (14:15 +0000)
committerMichael Brown <mcb30@ipxe.org>
Wed, 12 Mar 2025 14:27:44 +0000 (14:27 +0000)
commitd6ee9a9242f7f2c3ea1fad6959ff16481b34f6b3
tree67f0e2de364b2677dc13cf4c4a04047035f5134c
parent5f3ecbde5a68c503ee92becd5ddf427c317c94f1
[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>
src/core/cpio.c
src/tests/cpio_test.c [new file with mode: 0644]
src/tests/tests.c