Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: src/platform/vboot_reference/tests/firmware_image_tests.c

Issue 647027: Vboot Reference: Make firmware image verification test handle errors gracefully. (Closed)
Patch Set: Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/vboot_reference/tests/firmware_image_tests.c
diff --git a/src/platform/vboot_reference/tests/firmware_image_tests.c b/src/platform/vboot_reference/tests/firmware_image_tests.c
index db44f2e3daf5c8be984ac42bf544a4b38cb3efc7..42b44aba9dfa0118686db8847eff44d7eee9a6e4 100644
--- a/src/platform/vboot_reference/tests/firmware_image_tests.c
+++ b/src/platform/vboot_reference/tests/firmware_image_tests.c
@@ -136,10 +136,10 @@ int VerifyFirmwareTamperTest(FirmwareImage* image, RSAPublicKey* root_key) {
int main(int argc, char* argv[]) {
int len;
- uint8_t* sign_key_buf;
- FirmwareImage* image;
- RSAPublicKey* root_key;
- int success = 1;
+ uint8_t* sign_key_buf = NULL;
+ FirmwareImage* image = NULL;
+ RSAPublicKey* root_key = NULL;
+ int error_code = 1;
if(argc != 6) {
fprintf(stderr, "Usage: %s <algorithm> <root key> <processed root pubkey>"
@@ -153,26 +153,33 @@ int main(int argc, char* argv[]) {
image = GenerateTestFirmwareImage(atoi(argv[1]), sign_key_buf, 1,
1, 1000);
+ if (!root_key || !sign_key_buf || !image) {
+ error_code = 1;
+ goto failure;
+ }
+
/* Generate and populate signatures. */
if (!AddKeySignature(image, argv[2])) {
fprintf(stderr, "Couldn't create key signature.\n");
- return -1;
+ error_code = 1;
+ goto failure;
}
if (!AddFirmwareSignature(image, argv[4], image->sign_algorithm)) {
fprintf(stderr, "Couldn't create firmware and preamble signature.\n");
- return -1;
+ error_code = 1;
+ goto failure;
}
if (!VerifyFirmwareTest(image, root_key))
- success = 0;
+ error_code = 255;
if (!VerifyFirmwareTamperTest(image, root_key))
- success = 0;
+ error_code = 255;
- /* Clean up. */
+failure:
Free(root_key);
Free(sign_key_buf);
Free(image);
- return !success;
+ return error_code;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698