Repository navigation
fix: fractional seconds bounds check and TriggerMessage status handling - #461
Open
xPuffyPuffx wants to merge 1 commit into
Open
xPuffyPuffx wants to merge 1 commit into
xPuffyPuffx wants to merge 1 commit into
Conversation
- 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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses two issues identified during conformance and sanitizer testing with AddressSanitizer and UndefinedBehaviorSanitizer:
Fractional seconds bounds check and validation in
Timestamp::setTime(Time.cpp:82):When parsing fractional seconds (
jsonDateString[19] == '.'), the validator checked:Using logical OR (
||) instead of logical AND (&&) caused two problems:"2024-01-01T12:00:00."(length 20) or"2024-01-01T12:00:00.1"(length 21), indices 21 and 22 read 1–2 bytes past the null terminator (global/stack buffer overread caught by ASan)."2024-01-01T12:00:00.1abZ"),(c - '0')evaluated arbitrary ASCII characters as digits, generating corrupted millisecond values.Fix: Replaced
||with&&. Because&&short-circuits in C++ andisdigit('\0')is false, truncated strings stop immediately without reading past the buffer boundary.Return
NotImplementedfor unregistered operations inTriggerMessage(TriggerMessage.cpp:70):OperationRegistry::deserializeOperation()returns aRequestwrappingnew NotImplemented()rather thannullptrwhen an operation is unregistered.Because
if (msg)was always true,TriggerMessageerroneously setstatusMessage = "Accepted"and queued theNotImplementedobject intopreBootSendQueue, which later causedOperation::createReq()to emitUnsupported operation: createReq() is not implementedand transmit a bogus emptyCustomOperationCall frame.Fix: Checked
if (msg && !msg->getOperation()->getErrorCode())before accepting and queuing the operation.Verification
Tested with host Clang, ASan, and UBSan against boundary timestamps (
"2024-01-01T12:00:00.","2024-01-01T12:00:00.1","2024-01-01T12:00:00.123Z") and unregisteredTriggerMessagerequests. All unit tests pass with 0 sanitizer warnings.