[syslinux] Patch: Fix isohybrid.c tool under Windows platforms

Colin Finck colin at reactos.org
Mon Apr 10 03:21:16 PDT 2017


Hi all,

As part of a bigger effort to port the ISOLINUX hybrid mode to ReactOS,
I've encountered a bug in isohybrid under Windows platforms. Attached
comes a patch to fix it.

Precisely, if isohybrid currently finds a 0x0A (LF) byte in the MBR code
(which exists in the strings), it adds a 0x0D (CR) before, thereby
shifting the MBR bytes to the right and making it invalid.
This can be fixed by opening the file in binary mode with the "b" flag.

Cheers,

Colin
-------------- next part --------------
From 6642029cd0911d0432c8eb56d6344a53c7ad0b59 Mon Sep 17 00:00:00 2001
From: Colin Finck <colin at reactos.org>
Date: Thu, 19 Jan 2017 00:41:39 +0100
Subject: [PATCH] isohybrid: Open ISO file in binary mode to ensure that line
 endings stay untouched.

---
 utils/isohybrid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils/isohybrid.c b/utils/isohybrid.c
index 1a20321..a9e38d4 100644
--- a/utils/isohybrid.c
+++ b/utils/isohybrid.c
@@ -967,7 +967,7 @@ main(int argc, char *argv[])
 
     srand(time(NULL) << (getppid() << getpid()));
 
-    if (!(fp = fopen(argv[0], "r+")))
+    if (!(fp = fopen(argv[0], "rb+")))
         err(1, "could not open file `%s'", argv[0]);
 
     if (fseeko(fp, (off_t) (16 << 11), SEEK_SET))
-- 
1.9.5.msysgit.0



More information about the Syslinux mailing list