aboutsummaryrefslogtreecommitdiffstats
path: root/install.cpp
diff options
context:
space:
mode:
authorTom Marshall <tdm@cyngn.com>2015-11-05 21:30:40 -0800
committerTom Marshall <tdm@cyngn.com>2015-11-25 15:34:35 -0800
commitffc8a8702d9e1568995ce155c648fd029909cdac (patch)
tree3dcf3d34ebb03c3ac8d140d249e55838a90e2e14 /install.cpp
parent3381ac447175af3252c79c3e066cbbc38c400c85 (diff)
downloadbootable_recovery-ffc8a8702d9e1568995ce155c648fd029909cdac.zip
bootable_recovery-ffc8a8702d9e1568995ce155c648fd029909cdac.tar.gz
bootable_recovery-ffc8a8702d9e1568995ce155c648fd029909cdac.tar.bz2
recovery: Provide sideload cancellation
Change-Id: I13f0c9ae5444652a2141442ef24258679a78d320
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) {