]> git.saurik.com Git - cydia.git/commitdiff
Try to protect firmware.sh against reentrant bugs. v1.1.28%b6
authorJay Freeman (saurik) <saurik@saurik.com>
Sun, 29 Jan 2017 09:11:28 +0000 (01:11 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Sun, 29 Jan 2017 09:11:28 +0000 (01:11 -0800)
Library/firmware.sh

index afaae9a01d23c40380e4161dcb05b3bed2fe98ef..d2f89ebdf2b7f46ee949c5d710502f0c60281580 100755 (executable)
@@ -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