1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-19 22:50:17 +03:00

pcrlock: Pad pe hash to a multiple of 8 bytes

All other tools (sbsigntools, osslsigncode, sbctl, goblin) do this
as well so let's follow suite.

(cherry picked from commit e37701a8cd2db1e67d28bcf337467d8efc6de41e)
This commit is contained in:
Daan De Meyer 2024-11-03 21:45:29 +01:00 committed by Luca Boccassi
parent 4ea8428848
commit 9d22224e00

View File

@ -135,6 +135,10 @@ int pe_hash(int fd,
r = hash_file(fd, mdctx, p, st.st_size - p - certificate_table->Size);
if (r < 0)
return r;
/* If the file size is not a multiple of 8 bytes, pad the hash with zero bytes. */
if (st.st_size % 8 != 0 && EVP_DigestUpdate(mdctx, (const uint8_t[8]) {}, 8 - (st.st_size % 8)) != 1)
return log_debug_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE), "Unable to hash data.");
}
int hsz = EVP_MD_CTX_size(mdctx);