summaryrefslogtreecommitdiffstats
path: root/install.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'install.cpp')
-rw-r--r--install.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/install.cpp b/install.cpp
index 1bdf46b..7afcff6 100644
--- a/install.cpp
+++ b/install.cpp
@@ -22,6 +22,7 @@
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
+#include <setjmp.h>
#include <sys/mount.h>
#include "common.h"
@@ -47,6 +48,12 @@ static const float VERIFICATION_PROGRESS_FRACTION = 0.25;
static const float DEFAULT_FILES_PROGRESS_FRACTION = 0.4;
static const float DEFAULT_IMAGE_PROGRESS_FRACTION = 0.1;
+static jmp_buf jb;
+static void sig_bus(int sig)
+{
+ longjmp(jb, 1);
+}
+
// If the package contains an update binary, extract it and run it.
static int
try_update_binary(const char* path, ZipArchive* zip, bool* wipe_cache) {
@@ -306,7 +313,19 @@ really_install_package(const char *path, bool* wipe_cache, bool needs_mount)
ui->Print("Verifying update package...\n");
int err;
- err = verify_file(map.addr, map.length, loadedKeys, numKeys);
+
+ // Because we mmap() the update file which is backed by FUSE, we get
+ // SIGBUS when the host aborts the transfer. We handle this by using
+ // setjmp/longjmp.
+ signal(SIGBUS, sig_bus);
+ if (setjmp(jb) == 0) {
+ err = verify_file(map.addr, map.length, loadedKeys, numKeys);
+ }
+ else {
+ err = VERIFY_FAILURE;
+ }
+ signal(SIGBUS, SIG_DFL);
+
free(loadedKeys);
LOGI("verify_file returned %d\n", err);
if (err != VERIFY_SUCCESS) {