summaryrefslogtreecommitdiffstats
path: root/bmc
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2019-07-01 11:44:09 -0700
committerPatrick Venture <venture@google.com>2019-07-03 11:29:48 -0700
commit1999eef0e6ad3ab4ad6fcf58cce47f352ca5e137 (patch)
treeb13825bb3f50953ec6b50a24b7b8f9f4a8564081 /bmc
parentfd182168d9d1c852b1047b9eccea56812b614586 (diff)
downloadphosphor-ipmi-flash-1999eef0e6ad3ab4ad6fcf58cce47f352ca5e137.tar.gz
phosphor-ipmi-flash-1999eef0e6ad3ab4ad6fcf58cce47f352ca5e137.zip
bmc: only add verifyBlobId if data sent for image
If data was sent to the hash only, don't add verify until they've at least opened the image blob id. Signed-off-by: Patrick Venture <venture@google.com> Change-Id: Ifc03ac7090e7edbceeac414e908bc5aedb7ad1c3
Diffstat (limited to 'bmc')
-rw-r--r--bmc/firmware_handler.cpp9
-rw-r--r--bmc/test/firmware_state_uploadinprogress_unittest.cpp2
-rw-r--r--bmc/test/firmware_state_verificationpending_unittest.cpp12
3 files changed, 19 insertions, 4 deletions
diff --git a/bmc/firmware_handler.cpp b/bmc/firmware_handler.cpp
index 5f16846..855c3fa 100644
--- a/bmc/firmware_handler.cpp
+++ b/bmc/firmware_handler.cpp
@@ -642,8 +642,13 @@ bool FirmwareBlobHandler::close(uint16_t session)
/* They are closing a data pathway (image, tarball, hash). */
changeState(UpdateState::verificationPending);
- /* Add verify blob ID now that we can expect it. */
- addBlobId(verifyBlobId);
+ /* Add verify blob ID now that we can expect it, IIF they also wrote
+ * some data.
+ */
+ if (std::count(blobIDs.begin(), blobIDs.end(), activeImageBlobId))
+ {
+ addBlobId(verifyBlobId);
+ }
break;
case UpdateState::verificationPending:
/* They haven't triggered, therefore closing is uninteresting.
diff --git a/bmc/test/firmware_state_uploadinprogress_unittest.cpp b/bmc/test/firmware_state_uploadinprogress_unittest.cpp
index be3269e..63169db 100644
--- a/bmc/test/firmware_state_uploadinprogress_unittest.cpp
+++ b/bmc/test/firmware_state_uploadinprogress_unittest.cpp
@@ -193,7 +193,7 @@ TEST_F(FirmwareHandlerUploadInProgressTest,
handler->close(session);
expectedState(FirmwareBlobHandler::UpdateState::verificationPending);
- EXPECT_TRUE(handler->canHandleBlob(verifyBlobId));
+ EXPECT_FALSE(handler->canHandleBlob(verifyBlobId));
}
/*
diff --git a/bmc/test/firmware_state_verificationpending_unittest.cpp b/bmc/test/firmware_state_verificationpending_unittest.cpp
index fbcd73d..64d82ca 100644
--- a/bmc/test/firmware_state_verificationpending_unittest.cpp
+++ b/bmc/test/firmware_state_verificationpending_unittest.cpp
@@ -153,13 +153,23 @@ TEST_F(FirmwareHandlerVerificationPendingTest, StatOnActiveHashReturnsFailure)
TEST_F(FirmwareHandlerVerificationPendingTest,
StatOnVerificationBlobReturnsFailure)
{
- getToVerificationPending(hashBlobId);
+ getToVerificationPending(staticLayoutBlobId);
ASSERT_TRUE(handler->canHandleBlob(verifyBlobId));
blobs::BlobMeta meta;
EXPECT_FALSE(handler->stat(verifyBlobId, &meta));
}
+TEST_F(FirmwareHandlerVerificationPendingTest,
+ VerificationBlobNotFoundWithoutStaticDataAsWell)
+{
+ /* If you only ever open the hash blob id, and never the firmware blob id,
+ * the verify blob isn't added.
+ */
+ getToVerificationPending(hashBlobId);
+ EXPECT_FALSE(handler->canHandleBlob(verifyBlobId));
+}
+
TEST_F(FirmwareHandlerVerificationPendingTest, StatOnNormalBlobsReturnsSuccess)
{
getToVerificationPending(staticLayoutBlobId);
OpenPOWER on IntegriCloud