pe-binary: fix "systemd-sbsign calculates wrong PE checksum"

This commit is contained in:
hschloss
2026-05-12 14:15:05 +02:00
committed by Daan De Meyer
parent 0b8b2af657
commit 1ea3359793
+2 -1
View File
@@ -487,7 +487,8 @@ int pe_checksum(int fd, uint32_t *ret) {
return log_debug_errno(SYNTHETIC_ERRNO(EIO), "Short read from PE file");
for (size_t i = 0; i < (size_t) n / 2; i++) {
if (off + i >= checksum_offset && off + i < checksum_offset + sizeof(pe_header->optional.CheckSum))
size_t pos = off + i * sizeof(uint16_t);
if (pos >= checksum_offset && pos < checksum_offset + sizeof(pe_header->optional.CheckSum))
continue;
uint16_t val = le16toh(buf[i]);