summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2019-03-01 14:23:40 +0800
committerLei YU <mine260309@gmail.com>2019-03-13 11:01:53 +0800
commit91add6df04d65b4cddf9458e1c223163f9ad5764 (patch)
tree2d0efea118e88aad809e4df790df6d47be7b6148
parent6da3dae3b40bdbe9663b94e1f36dd3e2833d9c14 (diff)
downloadopenpower-pnor-code-mgmt-91add6df04d65b4cddf9458e1c223163f9ad5764.tar.gz
openpower-pnor-code-mgmt-91add6df04d65b4cddf9458e1c223163f9ad5764.zip
Static layout: Do not crash on empty PNOR
When PNOR is empty, or corrupted and it fails to retrieve the version, the service throws an exception. This is not good because it should run on a corrupted or empty PNOR, which then could be used to re-program the PNOR. This commit fixes the issue, by not throwing on the above case. Tested: Verify the service does not crash on a corrupted VERSION partition, and could be used to do code update to fix the corruption. Change-Id: Ic6a413a81ad13894a9c7f039df71fff9b9d4b2ad Signed-off-by: Lei YU <mine260309@gmail.com>
-rw-r--r--static/item_updater_static.cpp9
-rw-r--r--version.cpp3
2 files changed, 9 insertions, 3 deletions
diff --git a/static/item_updater_static.cpp b/static/item_updater_static.cpp
index 140d5cc5b..e4708ddee 100644
--- a/static/item_updater_static.cpp
+++ b/static/item_updater_static.cpp
@@ -218,6 +218,12 @@ void ItemUpdaterStatic::processPNORImage()
const auto& [version, extendedVersion] = Version::getVersions(fullVersion);
auto id = Version::getId(version);
+ if (id.empty())
+ {
+ // Possibly a corrupted PNOR
+ return;
+ }
+
auto activationState = server::Activation::Activations::Active;
if (version.empty())
{
@@ -347,7 +353,8 @@ bool ItemUpdaterStatic::freeSpace()
return erase(iter.second->versionId);
}
}
- return false;
+ // No active PNOR means PNOR is empty or corrupted
+ return true;
}
void ItemUpdaterStatic::updateFunctionalAssociation(
diff --git a/version.cpp b/version.cpp
index d9ad3954f..c6e43fc07 100644
--- a/version.cpp
+++ b/version.cpp
@@ -30,8 +30,7 @@ std::string Version::getId(const std::string& version)
if (version.empty())
{
log<level::ERR>("Error version is empty");
- elog<InvalidArgument>(Argument::ARGUMENT_NAME("Version"),
- Argument::ARGUMENT_VALUE(version.c_str()));
+ return {};
}
unsigned char digest[SHA512_DIGEST_LENGTH];
OpenPOWER on IntegriCloud