From 88b933330d110ad142fe8de2241dd4cc278fad15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 10 Apr 2021 20:06:56 +0200 Subject: [PATCH] [PEFIXUP] Only recalculate the PE checksum if the image is not from a reproducible build (original checksum == 0). (#3598) --- sdk/tools/pefixup.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/tools/pefixup.c b/sdk/tools/pefixup.c index 22d3d0c00fa..bb4f9ddaffc 100644 --- a/sdk/tools/pefixup.c +++ b/sdk/tools/pefixup.c @@ -283,10 +283,11 @@ int main(int argc, char **argv) if (!result) { - /* Success. Fix checksum and write to file */ - fix_checksum(buffer, len, nt_header); + /* Success. Recalculate the checksum only if this is not a reproducible build file */ + if (nt_header->OptionalHeader.CheckSum != 0) + fix_checksum(buffer, len, nt_header); - /* We could 'optimize by only writing the changed parts, but keep it simple for now */ + /* We could optimize by only writing the changed parts, but keep it simple for now */ fseek(file, 0, SEEK_SET); fwrite(buffer, 1, len, file); }