From c0cf446034edf89bba749b87c8c1b844ba02d226 Mon Sep 17 00:00:00 2001 From: Thierry Laurion Date: Tue, 31 Oct 2023 09:38:44 -0400 Subject: [PATCH] flash-gui.sh: add proper checks and cleanup in case of npf rom archive --- initrd/bin/flash-gui.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/initrd/bin/flash-gui.sh b/initrd/bin/flash-gui.sh index e1c79d61..4b66d5c0 100755 --- a/initrd/bin/flash-gui.sh +++ b/initrd/bin/flash-gui.sh @@ -43,9 +43,11 @@ while true; do # is a .npf provided? if [ -z "${ROM##*.npf}" ]; then + #preventive cleanup + rm -rf /tmp/verified_rom >/dev/null 2>&1 || true # unzip to /tmp/verified_rom - mkdir /tmp/verified_rom - unzip $ROM -d /tmp/verified_rom + mkdir -p /tmp/verified_rom >/dev/null 2>&1 || true + unzip $ROM -d /tmp/verified_rom || die "Failed to unzip ROM file" # check file integrity if (cd /tmp/verified_rom/ && sha256sum -cs /tmp/verified_rom/sha256sum.txt); then ROM="$(head -n1 /tmp/verified_rom/sha256sum.txt | cut -d ' ' -f 3)"