From 59f908ea6d93acb740240c11a0ea5c2d0796e127 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Fri, 23 Jan 2026 17:18:42 +0000 Subject: [PATCH] refactor(firmware): use od to read qcow2 magic bytes - Replace head-based check with od -tx1 to read first 4 bytes as hex - Compare hex string to 514649fb to detect qcow2 reliably - Avoid null-byte warnings from command substitution; keep same true/false output Fixes #1796 Signed-off-by: Martin Wimpress --- quickemu | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/quickemu b/quickemu index 8222ff8..9af973a 100755 --- a/quickemu +++ b/quickemu @@ -625,8 +625,11 @@ function configure_ram() { function is_firmware_qcow2() { # Check for the magic bytes that indicate the firmware is in qcow2 format, - # otherwise default to assuming firmware files are in raw format - [ "$(head -c 4 "$1")" = "QFI"$'\xfb' ] && echo "true" || echo "false" + # otherwise default to assuming firmware files are in raw format. + # Use od to read bytes as hex to avoid null byte warnings in command substitution. + local magic + magic=$(od -An -tx1 -N4 "$1" 2>/dev/null | tr -d ' ') + [ "$magic" = "514649fb" ] && echo "true" || echo "false" } function configure_bios() {