From 9aa074f8771c5d7a2e28c49f3261a504c59e01a3 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 7 Jul 2026 20:49:17 +0200 Subject: [PATCH] feat: Improve legacy .iso parsing (#1822) --- src/define.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/define.sh b/src/define.sh index 1281a49..7d773bb 100644 --- a/src/define.sh +++ b/src/define.sh @@ -1359,7 +1359,13 @@ addFolder() { local file file=$(find "$dest" -maxdepth 1 -type f -iname install.bat -print -quit) - [ -f "$file" ] && unix2dos -q "$file" + + if [ -f "$file" ]; then + if ! unix2dos -q "$file"; then + error "Failed to convert $file to DOS format!" + return 1 + fi + fi return 0 } @@ -1776,8 +1782,21 @@ prepareLegacy() { rm -f "$dir/$ETFS" local len offset - len=$(isoinfo -d -i "$iso" | grep "Nsect " | grep -o "[^ ]*$") - offset=$(isoinfo -d -i "$iso" | grep "Bootoff " | grep -o "[^ ]*$") + + if ! len=$(isoinfo -d -i "$iso" | grep "Nsect " | grep -o "[^ ]*$"); then + error "Failed to determine boot image size from $desc ISO!" + return 1 + fi + + if ! offset=$(isoinfo -d -i "$iso" | grep "Bootoff " | grep -o "[^ ]*$"); then + error "Failed to determine boot image offset from $desc ISO!" + return 1 + fi + + if [[ ! "$len" =~ ^[0-9]+$ ]] || [[ ! "$offset" =~ ^[0-9]+$ ]]; then + error "Invalid boot image location found in $desc ISO!" + return 1 + fi if ! dd "if=$iso" "of=$dir/$ETFS" bs=2048 "count=$len" "skip=$offset" status=none; then error "Failed to extract boot image from $desc ISO!" && return 1