From: Jay Freeman (saurik) Date: Sun, 29 Jan 2017 09:11:28 +0000 (-0800) Subject: Try to protect firmware.sh against reentrant bugs. X-Git-Tag: v1.1.28%b6^0 X-Git-Url: https://git.saurik.com/cydia.git/commitdiff_plain/ceffc5bc20c1ab16c4d02e1d3ae8fcfb65557797 Try to protect firmware.sh against reentrant bugs. --- diff --git a/Library/firmware.sh b/Library/firmware.sh index afaae9a0..d2f89ebd 100755 --- a/Library/firmware.sh +++ b/Library/firmware.sh @@ -49,6 +49,12 @@ EOF } # }}} +before=$(stat -c '%i-%Y' status) + +output=$(mktemp status-tmp.XXXXXX) +xxxxxx=${output##status-tmp.} +rm -f status-tmp.!("${xxxxxx}") + { # Delete Old Packages {{{ @@ -135,9 +141,11 @@ EOF pseudo "cy+lib.corefoundation" "$(/usr/libexec/cydia/cfversion)" "virtual corefoundation dependency" -} >"${status}"_ +} >"${output}" -mv -f "${status}"{_,} +# XXX: this is a poor replacement for flock +test "${before}" = "$(stat -c '%i-%Y' status)" +mv -f "${output}" "${status}" if [[ ${cpu} == arm || ${cpu} == arm64 ]]; then if [[ ! -h /User && -d /User ]]; then