mirror of
https://github.com/systemd/systemd.git
synced 2025-01-25 10:04:04 +03:00
pcrlock: Take VirtualSize > SizeOfRawData into account
If VirtualSize > SizeOfRawData, measure extra zeros to take into account the extra zeros also measured by the stub. (cherry picked from commit b53f2d5ed8ad0e537e9086daf84f9c2bf69fb72b)
This commit is contained in:
parent
92eca86c15
commit
206c1a0d5a
@ -216,10 +216,24 @@ int uki_hash(int fd,
|
|||||||
if (EVP_DigestInit_ex(mdctx, md, NULL) != 1)
|
if (EVP_DigestInit_ex(mdctx, md, NULL) != 1)
|
||||||
return log_debug_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE), "Failed to allocate message digest.");
|
return log_debug_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE), "Failed to allocate message digest.");
|
||||||
|
|
||||||
r = hash_file(fd, mdctx, section->PointerToRawData, section->VirtualSize);
|
r = hash_file(fd, mdctx, section->PointerToRawData, MIN(section->VirtualSize, section->SizeOfRawData));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
if (section->SizeOfRawData < section->VirtualSize) {
|
||||||
|
uint8_t zeroes[1024] = {};
|
||||||
|
size_t remaining = section->VirtualSize - section->SizeOfRawData;
|
||||||
|
|
||||||
|
while (remaining > 0) {
|
||||||
|
size_t sz = MIN(sizeof(zeroes), remaining);
|
||||||
|
|
||||||
|
if (EVP_DigestUpdate(mdctx, zeroes, sz) != 1)
|
||||||
|
return log_debug_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE), "Unable to hash data.");
|
||||||
|
|
||||||
|
remaining -= sz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hashes[i] = malloc(hsz);
|
hashes[i] = malloc(hsz);
|
||||||
if (!hashes[i])
|
if (!hashes[i])
|
||||||
return log_oom_debug();
|
return log_oom_debug();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user