From: hschloss Date: Wed, 6 May 2026 15:07:40 +0000 (+0200) Subject: pe-binary: fix "systemd-sbsign calculates wrong PE checksum" X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1ea3359793ffd1079b6f431f859ba1888dc218dd;p=thirdparty%2Fsystemd.git pe-binary: fix "systemd-sbsign calculates wrong PE checksum" --- diff --git a/src/shared/pe-binary.c b/src/shared/pe-binary.c index b4b180d7013..2f7764c1393 100644 --- a/src/shared/pe-binary.c +++ b/src/shared/pe-binary.c @@ -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]);