summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2020-01-22 14:50:46 -0600
committerMatt Spinler <spinler@us.ibm.com>2020-01-31 15:00:11 +0000
commit6d663820c905b03e50013bb1dd1bc6d2cf880405 (patch)
tree7cb78d23eb726b53df0645923916b11b1728a074
parentf1b46ff4a5db819f36888259d14364006e2b54da (diff)
downloadphosphor-logging-6d663820c905b03e50013bb1dd1bc6d2cf880405.tar.gz
phosphor-logging-6d663820c905b03e50013bb1dd1bc6d2cf880405.zip
PEL: Check UserData section size before adding
While not really likely, it is technically possible that the AdditionalData property in an event log is large enough that saving it into a UserData section could make the PEL exceed its maximum size of 16KB. To guard against this, check that an overflow wouldn't occur before saving that section in the PEL. In future commits, other UserData sections will be added where this check will also be needed. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: Iac312a24b1d445e93de5a09f35a43d940571a3f8
-rw-r--r--extensions/openpower-pels/pel.cpp7
-rw-r--r--extensions/openpower-pels/pel.hpp5
2 files changed, 11 insertions, 1 deletions
diff --git a/extensions/openpower-pels/pel.cpp b/extensions/openpower-pels/pel.cpp
index d1c9620..6d3f010 100644
--- a/extensions/openpower-pels/pel.cpp
+++ b/extensions/openpower-pels/pel.cpp
@@ -59,7 +59,12 @@ PEL::PEL(const message::Entry& entry, uint32_t obmcLogID, uint64_t timestamp,
if (!additionalData.empty())
{
auto ud = util::makeADUserDataSection(additionalData);
- _optionalSections.push_back(std::move(ud));
+
+ // To be safe, check there isn't too much data
+ if (size() + ud->header().size <= _maxPELSize)
+ {
+ _optionalSections.push_back(std::move(ud));
+ }
}
_ph->setSectionCount(2 + _optionalSections.size());
diff --git a/extensions/openpower-pels/pel.hpp b/extensions/openpower-pels/pel.hpp
index c3c9f5a..24e5e56 100644
--- a/extensions/openpower-pels/pel.hpp
+++ b/extensions/openpower-pels/pel.hpp
@@ -324,6 +324,11 @@ class PEL
*/
void printSectionInJSON(const Section& section, std::string& buf,
std::map<uint16_t, size_t>& pluralSections) const;
+
+ /**
+ * @brief The maximum size a PEL can be in bytes.
+ */
+ static constexpr size_t _maxPELSize = 16384;
};
namespace util
OpenPOWER on IntegriCloud