From e156df4354e0bed6fc45424c9e997a702a1900f5 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Thu, 31 Dec 2020 18:13:41 +0800 Subject: [PATCH] scripts: fit: validate image type of source file Signed-off-by: Joseph Chen Change-Id: Id04a4ef397fe19ffac3f09daeea6c5ebc9294dcd --- scripts/fit-msg.sh | 3 +++ scripts/fit-repack.sh | 3 +++ scripts/fit-resign.sh | 3 +++ scripts/fit-unpack.sh | 3 +++ 4 files changed, 12 insertions(+) diff --git a/scripts/fit-msg.sh b/scripts/fit-msg.sh index 941e6f2570..4767feb879 100755 --- a/scripts/fit-msg.sh +++ b/scripts/fit-msg.sh @@ -37,6 +37,9 @@ function args_process() if [ ! -f ${IMG} ]; then echo "ERROR: No ${IMG}" exit 1 + elif ! file ${IMG} | grep 'Device Tree Blob' ; then + echo "ERROR: ${IMG} is not FIT image" + exit 1 fi } diff --git a/scripts/fit-repack.sh b/scripts/fit-repack.sh index 054c295c6c..cc4a9718c2 100755 --- a/scripts/fit-repack.sh +++ b/scripts/fit-repack.sh @@ -48,6 +48,9 @@ function fit_repack() if [ ! -f ${IMAGE} ]; then echo "ERROR: No ${IMAGE}" exit 1 + elif ! file ${IMAGE} | grep 'Device Tree Blob' ; then + echo "ERROR: ${IMAGE} is not FIT image" + exit 1 elif [ ! -d ${DATA} ]; then echo "ERROR: No input directory ${DATA}" exit 1 diff --git a/scripts/fit-resign.sh b/scripts/fit-resign.sh index 752f6ea8df..44b0582bcf 100755 --- a/scripts/fit-resign.sh +++ b/scripts/fit-resign.sh @@ -51,6 +51,9 @@ function fit_resign() if [ ! -f ${ITB} ]; then echo "ERROR: No ${ITB}" exit 1 + elif ! file ${ITB} | grep 'Device Tree Blob' ; then + echo "ERROR: ${ITB} is not FIT image" + exit 1 elif [ ! -f ${SIG} ]; then echo "ERROR: No ${SIG}" exit 1 diff --git a/scripts/fit-unpack.sh b/scripts/fit-unpack.sh index e29c314681..43d104c2fe 100755 --- a/scripts/fit-unpack.sh +++ b/scripts/fit-unpack.sh @@ -41,6 +41,9 @@ function args_process() if [ ! -f ${ITB} ]; then echo "ERROR: No ${ITB}" exit 1 + elif ! file ${ITB} | grep 'Device Tree Blob' ; then + echo "ERROR: ${ITB} is not FIT image" + exit 1 fi if [ -z ${OUT} ]; then