Skip to content

Commit

Permalink
Merge pull request #151 from jphickey/fix-129-check-fd-pdu-flags
Browse files Browse the repository at this point in the history
Fix nasa#129, reject FD packets with segment_metadata flag set
  • Loading branch information
astrogeco authored Jan 12, 2022
2 parents cfe2881 + 0f2f11c commit 67259cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,14 @@ int CF_CFDP_RecvFd(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.error;
ret = -1;
}
else if (ph->pdu_header.segment_meta_flag)
{
/* If recv PDU has the "segment_meta_flag" set, this is not currently handled in CF. */
CFE_EVS_SendEvent(CF_EID_ERR_PDU_FD_UNSUPPORTED, CFE_EVS_EventType_ERROR,
"CF: filedata pdu with segment metadata received");
++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.error;
ret = -1;
}

return ret;
}
Expand Down
1 change: 1 addition & 0 deletions fsw/src/cf_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#define CF_EID_ERR_PDU_BAD_RX_MSG_SIZE 51
#define CF_EID_ERR_PDU_GET_EID_SIZE 52
#define CF_EID_ERR_PDU_GET_TSN_SIZE 53
#define CF_EID_ERR_PDU_FD_UNSUPPORTED 54

/* CF_CFDP event ids (engine) */
#define CF_EID_ERR_CFDP_RX_DROPPED 60
Expand Down
6 changes: 6 additions & 0 deletions unit-test/cf_cfdp_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,12 @@ void Test_CF_CFDP_RecvFd(void)
ph->int_header.fd.data_len = sizeof(CF_CFDP_uint32_t) - 1;
UtAssert_INT32_EQ(CF_CFDP_RecvFd(t, ph), -1);
UtAssert_BOOL_FALSE(CF_CODEC_IS_OK(ph->pdec));

/* with segment metadata (unimplemented) */
UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &t, NULL);
ph->pdu_header.segment_meta_flag = 1;
UtAssert_INT32_EQ(CF_CFDP_RecvFd(t, ph), -1);
UT_CF_AssertEventID(CF_EID_ERR_PDU_FD_UNSUPPORTED);
}

void Test_CF_CFDP_RecvEof(void)
Expand Down

0 comments on commit 67259cc

Please sign in to comment.