Skip to content

Commit 54e2e86

Browse files
author
Doug Zongker
committed
do not merge: cherry-picked 60151a2 from master branch
1 parent 0cf0e33 commit 54e2e86

File tree

3 files changed

+155
-330
lines changed

3 files changed

+155
-330
lines changed

install.c

+18-16
Original file line numberDiff line numberDiff line change
@@ -234,20 +234,8 @@ try_update_binary(const char *path, ZipArchive *zip) {
234234
}
235235

236236
static int
237-
handle_update_package(const char *path, ZipArchive *zip,
238-
const RSAPublicKey *keys, int numKeys)
237+
handle_update_package(const char *path, ZipArchive *zip)
239238
{
240-
// Give verification half the progress bar...
241-
ui_print("Verifying update package...\n");
242-
ui_show_progress(
243-
VERIFICATION_PROGRESS_FRACTION,
244-
VERIFICATION_PROGRESS_TIME);
245-
246-
if (!verify_jar_signature(zip, keys, numKeys)) {
247-
LOGE("Verification failed\n");
248-
return INSTALL_CORRUPT;
249-
}
250-
251239
// Update should take the rest of the progress bar.
252240
ui_print("Installing update...\n");
253241

@@ -360,19 +348,33 @@ install_package(const char *root_path)
360348
}
361349
LOGI("%d key(s) loaded from %s\n", numKeys, PUBLIC_KEYS_FILE);
362350

351+
// Give verification half the progress bar...
352+
ui_print("Verifying update package...\n");
353+
ui_show_progress(
354+
VERIFICATION_PROGRESS_FRACTION,
355+
VERIFICATION_PROGRESS_TIME);
356+
357+
int err;
358+
err = verify_file(path, loadedKeys, numKeys);
359+
free(loadedKeys);
360+
LOGI("verify_file returned %d\n", err);
361+
if (err != VERIFY_SUCCESS) {
362+
LOGE("signature verification failed\n");
363+
return INSTALL_CORRUPT;
364+
}
365+
363366
/* Try to open the package.
364367
*/
365368
ZipArchive zip;
366-
int err = mzOpenZipArchive(path, &zip);
369+
err = mzOpenZipArchive(path, &zip);
367370
if (err != 0) {
368371
LOGE("Can't open %s\n(%s)\n", path, err != -1 ? strerror(err) : "bad");
369372
return INSTALL_CORRUPT;
370373
}
371374

372375
/* Verify and install the contents of the package.
373376
*/
374-
int status = handle_update_package(path, &zip, loadedKeys, numKeys);
377+
int status = handle_update_package(path, &zip);
375378
mzCloseZipArchive(&zip);
376-
free(loadedKeys);
377379
return status;
378380
}

0 commit comments

Comments
 (0)