]> git.ipfire.org Git - thirdparty/systemd.git/commit
stub: Properly null-terminate filenames in pack_cpio_one
authorAdrian Vovk <adrianvovk@gmail.com>
Wed, 8 Dec 2021 02:01:46 +0000 (21:01 -0500)
committerAdrian Vovk <adrianvovk@gmail.com>
Wed, 8 Dec 2021 18:57:01 +0000 (13:57 -0500)
commitbf3f4d16d6426a26638d792f887f8e3fe86def94
treebf466ba3750cdbc585b712edbdeaf589efcce1e5
parentc65a0cf62f379e9b8fe33ab9bfe5cbcb6238cf56
stub: Properly null-terminate filenames in pack_cpio_one

Previously, mangle_filename would write the null terminator, but
then wouldn't increment the pointer. Thus, the pad4 call that comes
immediately after mangle_filename would trample over the null
terminator that mangle_filename wrote. Since the padding is all
0s, this happened to work for the filenames it was tested for

However, in some cases, this would cause the pointer to be a different
position than predicted. Basically, the predicted size would be one
byte bigger than the actual size (the missing null terminator). Usually,
this disappeared into the alignment padding at the end of the buffer,
but if the buffer was already unexpectedly aligned (b/c it was a byte
shorter than expected), this would cause assertion failures.

Also, the c_namesize field in the cpio header was incorrect. It
didn't include the null terminator, as required by the spec.
src/boot/efi/cpio.c