Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #277, Detect pdu truncation #310

Merged
merged 8 commits into from Aug 17, 2022
Merged

Fix #277, Detect pdu truncation #310

merged 8 commits into from Aug 17, 2022

Conversation

ghost
Copy link

@ghost ghost commented Aug 11, 2022

Checklist (Please check before submitting)

Describe the contribution
Fixes #277
Detects and reports silent truncation of Entity ID or Transaction Sequence Number fields.
PDUs with EID/TSN fields that are too big for configured internal storage will be rejected and an event will be issued.

Testing performed
Updated and ran unit and coverage tests.
Tested with peer-to-peer CF setup with both correctly configured PDU fields were accepted, and PDUs with size mismatches were rejected rather than silently truncated.

Expected behavior changes
Now if the ground or a peer sends a PDU with either EID or TSN fields that are too big for the storage configured in the cf_platform_cfg.h file, the PDU will be rejected, the error counter will be incremented, and an event message will be issued. Before these PDUs would be silently accepted, and the error could depend on the data truncation that would occur.

System(s) tested on

  • Hardware: PC
  • OS: Ubuntu 20.04
  • Versions: cFS bundle main (as of 8/11/2022)

Contributor Info - All information REQUIRED for consideration of pull request
Alan Cudmore, NASA/GSFC, Code 582.0

*/
if (CF_CFDP_DecodeHeader(ph->pdec, &ph->pdu_header) != CFE_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_PDU_TRUNCATION, CFE_EVS_EventType_ERROR,

Check warning

Code scanning / CodeQL-coding-standard

Unchecked return value

The return value of non-void function [CFE_EVS_SendEvent](1) is not checked.
{
CFE_EVS_SendEvent(CF_EID_ERR_PDU_TRUNCATION, CFE_EVS_EventType_ERROR,
"CF: pdu rejected due to eid/seq number field truncation");
++CF_AppData.hk.channel_hk[chan_num].counters.recv.error;

Check warning

Code scanning / CodeQL-coding-standard

Unchecked function argument

This use of parameter chan_num has not been checked.
* are larger than the sizes configured in the cf platform config
* file, then reject the PDU.
*/
if (CF_CFDP_DecodeHeader(ph->pdec, &ph->pdu_header) != CFE_SUCCESS)

Check warning

Code scanning / CodeQL-coding-standard

Side effect in a Boolean expression

This Boolean expression is not side-effect free.
@@ -822,9 +822,10 @@
* See description in cf_codec.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CF_CFDP_DecodeHeader(CF_DecoderState_t *state, CF_Logical_PduHeader_t *plh)
int32 CF_CFDP_DecodeHeader(CF_DecoderState_t *state, CF_Logical_PduHeader_t *plh)

Check notice

Code scanning / CodeQL-coding-standard

Long function without assertion

All functions of more than 10 lines should have at least one assertion.
@@ -822,9 +822,10 @@
* See description in cf_codec.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CF_CFDP_DecodeHeader(CF_DecoderState_t *state, CF_Logical_PduHeader_t *plh)
int32 CF_CFDP_DecodeHeader(CF_DecoderState_t *state, CF_Logical_PduHeader_t *plh)

Check notice

Code scanning / CodeQL-coding-standard

Use of basic integral type

CF_CFDP_DecodeHeader uses the basic integral type signed int rather than a typedef with size and signedness.
{
const CF_CFDP_PduHeader_t *peh; /* for decoding fixed sized fields */
int32 ret = CFE_SUCCESS;

Check notice

Code scanning / CodeQL-coding-standard

Use of basic integral type

ret uses the basic integral type signed int rather than a typedef with size and signedness.
@ghost ghost changed the title Fix #277 detect pdu truncation Fix #277, Detect pdu truncation Aug 11, 2022
@ghost ghost changed the title Fix #277, Detect pdu truncation Fix #277,Detect pdu truncation Aug 11, 2022
@ghost ghost changed the title Fix #277,Detect pdu truncation Fix #277, Detect pdu truncation Aug 11, 2022
@ghost
Copy link
Author

ghost commented Aug 11, 2022

Does anyone have an idea why the PR title check still fails on this request? I edited the PR title to add a comma, but it still says it fails with the old name. Is there anything I have to do outside of this page to edit that title?

docs/cf_FunctionalRequirements.csv Outdated Show resolved Hide resolved
fsw/src/cf_codec.c Show resolved Hide resolved
@dzbaker
Copy link
Contributor

dzbaker commented Aug 17, 2022

CCB 17 August 2022: Approved pending updates to new requirement:

  • Fix typo
  • Split into 2 requirements

@dzbaker dzbaker merged commit 8053882 into nasa:main Aug 17, 2022
@dzbaker dzbaker added this to the Draco milestone Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible silent truncations of entity ID and transaction sequence number
3 participants