From a0c5de1e32194ed14818c93e183ca6cbb076059a Mon Sep 17 00:00:00 2001 From: popcornmix Date: Mon, 22 Jul 2019 18:25:08 +0100 Subject: [PATCH] Sanity check contents of updated rpi-update See: https://github.com/Hexxeh/rpi-update/issues/285 --- rpi-update | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rpi-update b/rpi-update index b449c24..dbe810e 100755 --- a/rpi-update +++ b/rpi-update @@ -84,6 +84,12 @@ function update_self() { exit 1 fi + if [[ "$(head -1 ${_tempFileName})" != '#!/bin/bash' ]]; then + echo " !!! Failed to download update for rpi-update!" + echo " !!! Contents of file is not as expected - github may be down" + exit 1 + fi + local OCTAL_MODE=$(stat -c '%a' "$0") if ! chmod ${OCTAL_MODE} "${_tempFileName}" ; then echo " !!! Failed: Error while trying to set mode on ${_tempFileName}"