From 694bdf0f83d96fed38c8e56d6a4f0fdeb771eca1 Mon Sep 17 00:00:00 2001 From: xPuffyPuffx Date: Wed, 4 Nov 2026 14:23:51 +0100 Subject: [PATCH] fix: fractional seconds bounds check and TriggerMessage status handling - Ensure all fractional second characters in Timestamp::setTime are digits using conjunction &&, preventing out-of-bounds reads past string terminator and math corruption. - Check if deserialized operation carries an error code in TriggerMessage, returning NotImplemented instead of queuing an unsupported operation. --- src/MicroOcpp/Core/Time.cpp | 4 ++-- src/MicroOcpp/Operations/TriggerMessage.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MicroOcpp/Core/Time.cpp b/src/MicroOcpp/Core/Time.cpp index 1bcd0caa..c97c6942 100644 --- a/src/MicroOcpp/Core/Time.cpp +++ b/src/MicroOcpp/Core/Time.cpp @@ -82,8 +82,8 @@ bool Timestamp::setTime(const char *jsonDateString) { //optional fractals int ms = 0; if (jsonDateString[19] == '.') { - if (isdigit(jsonDateString[20]) || //1 - isdigit(jsonDateString[21]) || //2 + if (isdigit(jsonDateString[20]) && //1 + isdigit(jsonDateString[21]) && //2 isdigit(jsonDateString[22])) { ms = (jsonDateString[20] - '0') * 100 + diff --git a/src/MicroOcpp/Operations/TriggerMessage.cpp b/src/MicroOcpp/Operations/TriggerMessage.cpp index 9b930697..422e2aaf 100644 --- a/src/MicroOcpp/Operations/TriggerMessage.cpp +++ b/src/MicroOcpp/Operations/TriggerMessage.cpp @@ -68,7 +68,7 @@ void TriggerMessage::processReq(JsonObject payload) { } } else { auto msg = context.getOperationRegistry().deserializeOperation(requestedMessage); - if (msg) { + if (msg && !msg->getOperation()->getErrorCode()) { context.getRequestQueue().sendRequestPreBoot(std::move(msg)); statusMessage = "Accepted"; } else {