From 5ccc0757901419acc3b2decdac86ac133eb9647c Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sat, 10 Mar 2018 23:35:20 +0800 Subject: checksum_image(): Fix md5 check when given file doesn't exist --- dfly-update | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'dfly-update') diff --git a/dfly-update b/dfly-update index 68efc99..e4666eb 100755 --- a/dfly-update +++ b/dfly-update @@ -32,6 +32,7 @@ EC_VN=17 EC_TAR=18 EC_MTREE=19 EC_CPDUP=20 +EC_NOFILE=21 # @@ -266,8 +267,9 @@ checksum_image() { local file="$1" local md5_match="$2" local md5 - [ -f "${file}" ] && md5=$(md5 -q "${file}") - if [ -n "${md5}" ] && [ "${md5}" = "${md5_match}" ]; then + [ -f "${file}" ] || error ${EC_NOFILE} "checksum_image: file not exists" + md5=$(md5 -q "${file}") + if [ "${md5}" = "${md5_match}" ]; then return 0 else return 1 -- cgit v1.2.2