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

Thomas Schmitt scdbackup at gmx.net
Mon Apr 17 06:44:12 PDT 2017


Hi,

i wrote:
> > Not only MBR writing but also reading of the Primary Volume Descriptor
> > and of the El Torito catalog by isohybrid.c are currently prone to
> > unwanted CR-insertion. Miscalculations can be caused by this.

I have to correct myself: Carriage Return characters (byte value 13 = 0x0d)
are not at risk to be inserted, but rather to be removed if they happen
to be followed by a New Line character (value 10 = 0x0a).

So for example the block address bytes 0d 0a 00 00 (= 2573 decimal) of the
BIOS boot image in the default entry of the boot catalog would be crippled
during fread() in
  http://git.zytor.com/syslinux/syslinux.git/tree/utils/isohybrid.c#n997 
and then misinterpreted in function read_catalogue() when variable de_lba
gets set:
  http://git.zytor.com/syslinux/syslinux.git/tree/utils/isohybrid.c#n519
de_lba is the value which gets written to byte 432 ff. in the isohybrid MBR.

During boot the MBR would hopefully see a wrong signature and refuse with
  "isolinux.bin missing or corrupt.\r\n"
rather than executing the bytes at the wrong address as program code
(which would be quite scary).


Ady wrote:
> Is there anything that can be done in order to reduce such chances of 
> miscalculation and/or unwanted insertion of (CR) characters?

The appropriate remedy is to use "b" with fopen().

Its absence in isohybrid.c is an obvious translation error which happened
when the perl lines at
  http://git.zytor.com/syslinux/syslinux.git/tree/utils/isohybrid.in#n133

  open(FILE, "+< $file\0") or die "$0: cannot open $file: $!\n";
  binmode FILE;

were converted to the C lines at
  http://git.zytor.com/syslinux/syslinux.git/tree/utils/isohybrid.c#n970

      if (!(fp = fopen(argv[0], "r+")))
          err(1, "could not open file `%s'", argv[0]);


> So, is there any reason not to apply the suggested patch? Any potential 
> compatibility issues? Backward compatibility between different versions 
> of isohybrid and isolinux.bin? Anything?

No. It's just a bug fix.
The bug has years of tradition. But it is very hard to imagine any use of
its more or less random alterations of bytes which happen only on DOS
descendants but not on Unix.
 

Have a nice day :)

Thomas



More information about the Syslinux mailing list