Fix undefined behavior in timestamp parsing
If this algorithm ever processed a string where the + came before the .,
then dot - plus would render a negative, and overflow, causing a crash.
In practice, this doesn't happen.
Tested: Inspection only at this time. Difficult to trigger error.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ic7f5153d144ac551118c4f4b2d61f82626ac3779
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 1785828..7e249ba 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -247,7 +247,7 @@
// RFC3339 format which matches the Redfish format except for the
// fractional seconds between the '.' and the '+', so just remove them.
std::size_t dot = timestamp.find_first_of('.');
- std::size_t plus = timestamp.find_first_of('+');
+ std::size_t plus = timestamp.find_first_of('+', dot);
if (dot != std::string::npos && plus != std::string::npos)
{
timestamp.erase(dot, plus - dot);