# HG changeset patch # User Pascal Bellard # Date 1420317708 -3600 # Node ID aa46cf9cc35a92b842674d9252101358b1394f00 # Parent 2c2a6dd5ba40517b6d49dc18ce941efaf1f4723b syslinux/iso2exe: check ISO md5 diff -r 2c2a6dd5ba40 -r aa46cf9cc35a syslinux/stuff/iso2exe/boot.c --- a/syslinux/stuff/iso2exe/boot.c Fri Jan 02 21:46:16 2015 +0100 +++ b/syslinux/stuff/iso2exe/boot.c Sat Jan 03 21:41:48 2015 +0100 @@ -71,10 +71,12 @@ loadinitrd(); } if (*init) { - lseek(isofd, 24L, SEEK_SET); + lseek(isofd, 20L, SEEK_SET); + read(isofd, &isofileofs, 4); + isofileofs &= 0xFFFFL; read(isofd, &magic, 4); isofilesize = magic & 0xFFFFL; - isofileofs = 0x7EE0L - isofilesize; + isofileofs -= 0xC0L + isofilesize; if (isofilesize) loadinitrd(); else init=""; } diff -r 2c2a6dd5ba40 -r aa46cf9cc35a syslinux/stuff/iso2exe/init --- a/syslinux/stuff/iso2exe/init Fri Jan 02 21:46:16 2015 +0100 +++ b/syslinux/stuff/iso2exe/init Sat Jan 03 21:41:48 2015 +0100 @@ -1,6 +1,7 @@ #!/bin/sh DIALOG=dialog +ISOMD5= ddq() { @@ -118,7 +119,7 @@ { echo "Creating $(basename $1) ..." O=$(($(get 66 /mnt/$ISO) - 0xC0)) - L=$((0x7EE0 - $(get 24 /mnt/$ISO) - $O)) + L=$(($(get 20 /mnt/$ISO) - 0xC0 - $(get 24 /mnt/$ISO) - $O)) S=$((32+$L)) P=$((($S+511)/512)) E=$((4096-(32*$P))) @@ -635,6 +636,21 @@ echo -en "\"$1\" \"$2\"" } +gotisomd5() +{ + [ "$(which md5sum 2> /dev/null)" ] && [ "$ISOMD5" ] && + echo -en "\"$1\" \"$2\"" +} + +isomd5() +{ + dotwait "Checking iso image" + [ "$(ddq if=/dev/loop0 bs=32k skip=1 | md5sum)" == "$ISOMD5 -" ] && + echo "OK" || echo "ERROR" + rm -f /tmp/wait + sleep 5 +} + fdbootstrap() { sz=$((512 * $(echo $(get 28 /mnt/$ISO 1)))) @@ -886,8 +902,9 @@ $(cdfile boot/bzImage "live" "Linux RAM boot (full desktop)") \ "text" "Linux RAM boot" \ $(cdfile README* "readme" "Show the README file") \ -$(cdfile md5sum* "md5" "Check ISO files") \ -$(cdfile sha*sum* "sha" "Check ISO files") \ +$(gotisomd5 "isomd5" "Check the ISO image") \ +$(cdfile md5sum* "md5" "Check the ISO files") \ +$(cdfile sha*sum* "sha" "Check the ISO files") \ $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \ $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \ $(xfile tazusb "usbkey" "USB key read/write installation") \ diff -r 2c2a6dd5ba40 -r aa46cf9cc35a syslinux/stuff/iso2exe/iso2exe.sh --- a/syslinux/stuff/iso2exe/iso2exe.sh Fri Jan 02 21:46:16 2015 +0100 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Sat Jan 03 21:41:48 2015 +0100 @@ -37,6 +37,11 @@ mkdir -p $TMP/bin $TMP/dev cp -a /dev/?d?* /dev/tty /dev/tty0 $TMP/dev $0 --get init > $TMP/init.exe + if [ $(stat -c %s $1) -gt 32768 ]; then + echo "Compute ISO image md5 ..." + sed -i "s/^ISOMD5.*/ISOMD5=$(ddq if=$1 bs=32k skip=1 | \ + md5sum | cut -c-32)/" $TMP/init.exe + fi # mount -o loop,ro $1 $TMP # oldslitaz="$(ls $TMP/boot/isolinux/splash.lss 2> /dev/null)" # umount -d $TMP @@ -57,10 +62,12 @@ add_dosexe() { - OFS=$((0x7EE0)) - printf "Adding DOS/EXE at %04X (%d bytes) ...\n" $OFS $((0x8000 - $OFS)) - $0 --get bootiso.bin 2> /dev/null | \ - ddq bs=1 skip=$OFS of=$1 seek=$OFS conv=notrunc + TMP=/tmp/bootiso$$ + $0 --get bootiso.bin > $TMP 2> /dev/null + OFS=$(($(get 20 $TMP) - 0xC0)) + printf "Adding DOS/EXE stub at %04X (%d bytes) ...\n" $OFS $((0x8000 - $OFS)) + ddq if=$TMP bs=1 skip=$OFS of=$1 seek=$OFS conv=notrunc + rm -f $TMP } add_doscom()