Add destCapacity DeserializeTo for more robustness#5043
Open
bitWarrior wants to merge 9 commits intonasa:develfrom
Open
Add destCapacity DeserializeTo for more robustness#5043bitWarrior wants to merge 9 commits intonasa:develfrom
bitWarrior wants to merge 9 commits intonasa:develfrom
Conversation
added 4 commits
April 17, 2026 16:59
Collaborator
|
Blocked on CCB approval |
| } | ||
|
|
||
| SerializeStatus LinearBufferBase::deserializeTo(U8* buff, Serializable::SizeType& length, Endianness endianMode) { | ||
| SerializeStatus LinearBufferBase::deserializeTo(U8* buff, |
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.
Change Description
Added destCapacity param:
[+] SerializeStatus deserializeTo(U8* buff, SizeType buffCapacity, SizeType& length, bool noLength);
Rationale
Adding a destCapacity parameter allows for an extra check to ensure the memcpy does not overflow. Undesirable things could happen if it does.
What Changed
LinearBufferBase/SerialBufferBase(Fw/Types/Serializable.hpp)The two byte-buffer overloads of
deserializeTonow require an explicit destination capacity:SerialBuffer(Fw/Types/SerialBuffer.hpp)popBytesnow requires an explicit destination capacity:Deprecated overloads removed
The following deprecated
deserialize(U8* buff, ...)overloads could not be safely forwarded to the new signatures and have been removed. They were already markedDEPRECATEDin prior releases:deserialize(U8* buff, FwSizeType& length, bool noLength)deserializeTo(buff, buffCapacity, length, lengthMode)deserialize(U8* buff, FwSizeType& length)deserializeTo(buff, buffCapacity, length)deserialize(U8* buff, FwSizeType& length, Serialization::t mode)deserializeTo(buff, buffCapacity, length, mode)New Runtime Behavior
FW_DESERIALIZE_SIZE_MISMATCHis now returned in two additional situations:buffCapacity(previously only checked against source bytes remaining).buffisnullptrwhilebuffCapacity > 0.In both cases the deserialization cursor is not advanced, so callers can handle the error and retry or report without corrupting deserialization state.
Migration Guide
Step 1 — Find all call sites
Search your codebase for calls to the affected functions:
Focus on overloads that take a
U8*destination buffer. Scalar overloads (e.g.,deserializeTo(U32& val)) are not affected.Step 2 — Add the
buffCapacityargumentInsert the size of the destination buffer as the second argument, immediately after the pointer.
deserializeTo— stack array:deserializeTo— heap / external buffer:popBytes:Step 3 — Remove calls to deprecated overloads
If your code still uses the removed
deserialize(U8* buff, ...)overloads (which emitted compiler warnings in prior releases), migrate them todeserializeTowith the capacity argument as shown in Step 2.Step 4 — Handle the new error path
If your code already checks the return value of
deserializeToorpopBytes(as it should), no further changes are needed —FW_DESERIALIZE_SIZE_MISMATCHis not a new status code. However, if you previously assumed that a successful deserialize meant the source data fit the destination, you may want to add a log or assertion to distinguish this case for easier debugging:Testing/Review Recommendations
regression_test_deserializeTo.sh
Affected Files (Framework)
Fw/Types/Serializable.hpp/.cppbuffCapacityparam ondeserializeTobyte-buffer overloads; deprecated overloads removedFw/Types/SerialBuffer.hpp/.cppbuffCapacityparam onpopBytesFw/Types/StringBase.cppdeserializeFromcall siteFw/Tlm/TlmPacket.cppextractValueanddeserializeFromcall sitesFw/Log/LogPacket.cppFw/Log/AmpcsEvrLogPacket.cppFw/Dp/DpContainer.cppFw/FilePacket/PathName.cpppopBytescall siteSvc/CmdSequencer/FPrimeSequence.cppSvc/CmdSequencer/formats/AMPCSSequence.cppSvc/FpySequencer/FpySequencerRunState.cppSvc/DpCatalog/DpCatalog.cppSvc/PrmDb/PrmDbImpl.cppRef/RecvBuffApp/RecvBuffComponentImpl.cppFuture Work
N/A
AI Usage (see policy)
AI was used to generate the new unit tests