Repository navigation
fix(AosDeframer): use FwSizeType for iteration bound to prevent packet loss (#6426) - #6428
jaideepkrishna2008-ui wants to merge 1 commit into
Conversation
…t loss (nasa#6426) In AosDeframer::extractPackets, maxIters was computed by casting (dataZoneSize - firstHeaderPointer) to FwIndexType. On standard Unix targets, FwIndexType is signed 16-bit (I16, max 32767). When processing large AOS frames (up to 65,536 octets per CCSDS 131.0-B-6), a dataZoneSize > 32767 causes this static_cast to narrow into a negative value (e.g., 65526 -> -10). The extraction loop condition (iter < maxIters) evaluates to false on the first check, silently skipping packet extraction and discarding all packets in the frame without reporting an error. Change maxIters and the loop counter iter to FwSizeType, which matches the native byte size type of dataZoneSize and currentOffset, eliminating narrowing integer overflow. Fixes nasa#6426
|
Hello @jaideepkrishna2008-ui, and thank you for contributing to F´! This pull request is signed At the moment the linked issue(s) have not yet been approved by the CCB: #6426 (CCB Resolution: not yet set). Recommendation to maintainers: close this PR for now, and reopen it once the CCB has weighed in on the linked issue(s). If the CCB approves, the work here can be picked back up immediately. This is an automated notice from |
|
Thanks for contributing to F Prime. This ticket has not passed CCB and I am therefore closing this PR. Please read through our contributing guide. |
Change Description
In
Svc/Ccsds/AosDeframer/AosDeframer.cpp(extractPackets), updated the packet extraction loop bound and counter:const FwIndexType maxIters = static_cast<FwIndexType>(dataZoneSize - firstHeaderPointer);toconst FwSizeType maxIters = dataZoneSize - firstHeaderPointer;.FwIndexType iter = 0toFwSizeType iter = 0.Rationale
Fixes #6426.
In
AosDeframer::extractPackets,maxIterswas calculated by casting(dataZoneSize - firstHeaderPointer)toFwIndexType. On standard Unix platforms,FwIndexTypeis configured as a signed 16-bit integer (I16, maximum value 32,767).When a mission configures large AOS frames (up to 65,536 octets per CCSDS 131.0-B-6),
dataZoneSize - firstHeaderPointer(e.g., 65,526 octets) exceedsstd::numeric_limits<FwIndexType>::max(). Thestatic_cast<FwIndexType>narrows the unsigned byte count into a negative value (e.g.,-10). As a result, the loop conditioniter < maxItersevaluates to false on the very first iteration, silently skipping packet extraction entirely and discarding all packets in the frame without reporting an error.Using
FwSizeTypealignsmaxItersanditerwith the native unsigned byte size type used throughout the component (dataZoneSize,firstHeaderPointer,currentOffset), eliminating narrowing integer overflow.Testing/Review Recommendations
FwIndexTypeproduced-10, resulting in0iterations and dropped packets.FwSizeTypecorrectly computedmaxIters = 65526and allowed the extraction loop to execute fully.dataZoneSizeandcurrentOffsetare already typed asFwSizeType, soFwSizeTypeis the natural and uniform type for the iteration bound.Future Work
None needed for this fix.
Contributor Checklist
AI Usage (see policy)
AI was used for codebase inspection, arithmetic analysis of the narrowing conversion, and drafting the standalone reproducer and pull request text.
AGENTS.md).IAMAI