From 1e2ce169af0f1fb40ef9906f33b137cf877b8dae Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 3 Dec 2022 23:41:42 -0800 Subject: [PATCH] Fix unaligned end-of-file certificates --- BurnOutSharp.Builder/PortableExecutable.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BurnOutSharp.Builder/PortableExecutable.cs b/BurnOutSharp.Builder/PortableExecutable.cs index 6ce2aa13..b3648ee7 100644 --- a/BurnOutSharp.Builder/PortableExecutable.cs +++ b/BurnOutSharp.Builder/PortableExecutable.cs @@ -715,7 +715,7 @@ namespace BurnOutSharp.Builder attributeCertificateTable.Add(entry); // Align to the 8-byte boundary - while ((offset % 8) != 0) + while (offset < data.Length - 1 && (offset % 8) != 0) _ = data.ReadByte(ref offset); } @@ -1866,7 +1866,7 @@ namespace BurnOutSharp.Builder attributeCertificateTable.Add(entry); // Align to the 8-byte boundary - while ((data.Position % 8) != 0) + while (data.Position < data.Length - 1 && (data.Position % 8) != 0) _ = data.ReadByteValue(); }