Skip to content

fix(AosDeframer): use FwSizeType for iteration bound to prevent packet loss (#6426) - #6428

Closed
jaideepkrishna2008-ui wants to merge 1 commit into
nasa:develfrom
jaideepkrishna2008-ui:fix/aos-deframer-maxiters-narrowing
Closed

jaideepkrishna2008-ui wants to merge 1 commit into
nasa:develfrom
jaideepkrishna2008-ui:fix/aos-deframer-maxiters-narrowing

Conversation

@jaideepkrishna2008-ui

Copy link
Copy Markdown
Related Issue(s) #6426
Has Unit Tests (y/n) y
Documentation Included (y/n) n
Generative AI was used in this contribution (y/n) AI

Change Description

In Svc/Ccsds/AosDeframer/AosDeframer.cpp (extractPackets), updated the packet extraction loop bound and counter:

  • Changed const FwIndexType maxIters = static_cast<FwIndexType>(dataZoneSize - firstHeaderPointer); to const FwSizeType maxIters = dataZoneSize - firstHeaderPointer;.
  • Changed the loop variable from FwIndexType iter = 0 to FwSizeType iter = 0.

Rationale

Fixes #6426.

In AosDeframer::extractPackets, maxIters was calculated by casting (dataZoneSize - firstHeaderPointer) to FwIndexType. On standard Unix platforms, FwIndexType is 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) exceeds std::numeric_limits<FwIndexType>::max(). The static_cast<FwIndexType> narrows the unsigned byte count into a negative value (e.g., -10). As a result, the loop condition iter < maxIters evaluates to false on the very first iteration, silently skipping packet extraction entirely and discarding all packets in the frame without reporting an error.

Using FwSizeType aligns maxIters and iter with the native unsigned byte size type used throughout the component (dataZoneSize, firstHeaderPointer, currentOffset), eliminating narrowing integer overflow.

Testing/Review Recommendations

  • Verified arithmetic and loop behavior with a standalone C++ reproducer compiling with GCC:
    • Narrowing FwIndexType produced -10, resulting in 0 iterations and dropped packets.
    • Using FwSizeType correctly computed maxIters = 65526 and allowed the extraction loop to execute fully.
  • Reviewers can verify that dataZoneSize and currentOffset are already typed as FwSizeType, so FwSizeType is 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.

IAMAI

…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
@lestarch-autobot

Copy link
Copy Markdown
Collaborator

Hello @jaideepkrishna2008-ui, and thank you for contributing to F´!

This pull request is signed IAMAI, indicating it was produced by an AI agent. Per the contributor guidelines, all code contributions begin with an issue that is reviewed and approved by the Change Control Board (CCB) before implementation work starts. This gate exists to keep limited maintainer review time focused on work that is in scope for F´.

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 lestarch-autobot. It is a process note, not a judgment on the quality of the contribution.

@thomas-bc-autowot thomas-bc-autowot added bug CCB PR needs to go through CCB process labels Nov 21, 2026
@thomas-bc

Copy link
Copy Markdown
Collaborator

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.

@thomas-bc thomas-bc closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug CCB PR needs to go through CCB process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Svc/Ccsds/AosDeframer: FwIndexType narrowing skips packet extraction for large AOS frames

4 participants