From acf5c733c2fa74ac59cb8a4f3352ff0dc56443c8 Mon Sep 17 00:00:00 2001 From: n1073645 Date: Fri, 15 Nov 2019 09:26:49 +0000 Subject: [PATCH] Tidied up local and global variables for Mach-o --- src/core/lib/FileSignatures.mjs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/lib/FileSignatures.mjs b/src/core/lib/FileSignatures.mjs index 2ef390cd..cf8a5373 100644 --- a/src/core/lib/FileSignatures.mjs +++ b/src/core/lib/FileSignatures.mjs @@ -2737,6 +2737,11 @@ export function extractZIP(bytes, offset) { */ export function extractMACHO(bytes, offset) { + // Magic bytes. + const MHCIGAM64 = "207250237254"; + const MHMAGIC64 = "254237250207"; + const MHCIGAM = "206250237254"; + /** * Checks to see if the file is 64-bit. @@ -2771,6 +2776,9 @@ export function extractMACHO(bytes, offset) { */ function dumpSegmentCommands(stream, offset, isSwap, ncmds) { let total = 0; + const LCSEGEMENT64 = 0x19; + const LCSEGEMENT = 0x1; + for (let i = 0; i < ncmds; i++) { // Move to start of segment. @@ -2820,12 +2828,6 @@ export function extractMACHO(bytes, offset) { } - const MHCIGAM64 = "207250237254"; - const MHMAGIC64 = "254237250207"; - const MHCIGAM = "206250237254"; - const LCSEGEMENT64 = 0x19; - const LCSEGEMENT = 0x1; - const stream = new Stream(bytes.slice(offset)); const magic = stream.getBytes(4).join("");