feat: Limit xorriso boot image extraction size (#2019)

This commit is contained in:
Kroese
2026-07-29 04:09:18 +02:00
committed by GitHub
parent 38e732ea79
commit 7ec498e3f2
+24 -5
View File
@@ -524,6 +524,13 @@ detectLegacy() {
[[ "${PLATFORM,,}" == "x64" ]] || return 1 [[ "${PLATFORM,,}" == "x64" ]] || return 1
marker=$(find "$dir" -maxdepth 1 -type d -iname 'ia64' -print -quit) || return 1
if [ -n "$marker" ]; then
error "Windows IA-64 (Itanium) images are not supported by this container!"
return 1
fi
marker=$(find "$dir" -maxdepth 1 -type d -iname WIN95 -print -quit) || return 1 marker=$(find "$dir" -maxdepth 1 -type d -iname WIN95 -print -quit) || return 1
if [ -n "$marker" ]; then if [ -n "$marker" ]; then
@@ -612,7 +619,8 @@ detectLegacy() {
-iname WIN51AD -o \ -iname WIN51AD -o \
-iname WIN51AS -o \ -iname WIN51AS -o \
-iname WIN51MA -o \ -iname WIN51MA -o \
-iname WIN51MD \ -iname WIN51MD -o \
-iname WIN51MP \
\) \ \) \
-print -quit) || return 1 -print -quit) || return 1
@@ -1110,6 +1118,7 @@ extractBootImage() {
local rc size offset image="" local rc size offset image=""
local msg="using legacy extraction..." local msg="using legacy extraction..."
local expected_size=$((BOOT_LOAD_SIZE * 512)) local expected_size=$((BOOT_LOAD_SIZE * 512))
local max_extract_size=$((64 * 1024 * 1024))
local boot_info local boot_info
local -a images=() local -a images=()
@@ -1119,12 +1128,17 @@ extractBootImage() {
rm -f "$dir/$ETFS" || return 1 rm -f "$dir/$ETFS" || return 1
rm -rf "$tmp" || return 1 rm -rf "$tmp" || return 1
if LC_ALL=C xorriso \ if command -v prlimit >/dev/null 2>&1; then
LC_ALL=C prlimit \
"--fsize=$max_extract_size:$max_extract_size" \
xorriso \
-no_rc \ -no_rc \
-osirrox on \ -osirrox on \
-indev "$iso" \ -indev "$iso" \
-extract_boot_images "$tmp" >/dev/null 2>&1; then -extract_boot_images "$tmp" >/dev/null 2>&1
rc=$?
if (( rc == 0 )); then
mapfile -t images < <( mapfile -t images < <(
find "$tmp" \ find "$tmp" \
-maxdepth 1 \ -maxdepth 1 \
@@ -1159,9 +1173,10 @@ extractBootImage() {
warn "No BIOS boot image was found, $msg" warn "No BIOS boot image was found, $msg"
fi fi
else elif (( rc == 153 )); then
rc=$? info "The extracted BIOS boot image exceeded the size limit, $msg"
else
if (( rc > 128 )); then if (( rc > 128 )); then
rm -rf "$tmp" || true rm -rf "$tmp" || true
exit "$rc" exit "$rc"
@@ -1170,6 +1185,10 @@ extractBootImage() {
warn "Failed to extract the BIOS boot image, $msg" warn "Failed to extract the BIOS boot image, $msg"
fi fi
else
warn "The prlimit utility is unavailable, $msg"
fi
rm -rf "$tmp" || true rm -rf "$tmp" || true
if ! boot_info=$(isoinfo -d -i "$iso"); then if ! boot_info=$(isoinfo -d -i "$iso"); then