From a3f8e49a0dc6d613a93bde9ed9173c2760e8599d Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 17 Feb 2019 22:57:05 +0100 Subject: [PATCH] Use a temporary copy of our tar binary during OTA updating, to avoid the potential for a SIGBUS error... Fix #4602 --- platform/kindle/koreader.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/kindle/koreader.sh b/platform/kindle/koreader.sh index 50d2a86b0..b45a144ad 100755 --- a/platform/kindle/koreader.sh +++ b/platform/kindle/koreader.sh @@ -107,9 +107,14 @@ ko_update_check() { FILESIZE="$(stat -c %b "${NEWUPDATE}")" BLOCKS="$((FILESIZE / 20))" export CPOINTS="$((BLOCKS / 100))" + # NOTE: To avoid blowing up when tar truncates itself during an update, copy our GNU tar binary to the system's tmpfs, + # and run that one (c.f., #4602)... + cp -pf ./tar /var/tmp/gnutar # shellcheck disable=SC2016 - ./tar --no-same-permissions --no-same-owner --checkpoint="${CPOINTS}" --checkpoint-action=exec='./fbink -q -y -6 -P $(($TAR_CHECKPOINT/$CPOINTS))' -C "/mnt/us" -xf "${NEWUPDATE}" + /var/tmp/gnutar --no-same-permissions --no-same-owner --checkpoint="${CPOINTS}" --checkpoint-action=exec='./fbink -q -y -6 -P $(($TAR_CHECKPOINT/$CPOINTS))' -C "/mnt/us" -xf "${NEWUPDATE}" fail=$? + # And remove our temporary tar binary... + rm -f /var/tmp/gnutar # Cleanup behind us... if [ "${fail}" -eq 0 ]; then mv "${NEWUPDATE}" "${INSTALLED}"