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 #95, reject PDUs with large bit set #179

Merged
merged 1 commit into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,19 @@ int CF_CFDP_RecvPh(uint8 chan_num, CF_Logical_PduBuffer_t *ph)

CF_CFDP_DecodeHeader(ph->pdec, &ph->pdu_header);

/*
* The "large file" flag is not supported by this implementation yet.
* This means file sizes and offsets will be 64 bits, so codec routines
* will need to be updated to understand this. OSAL also doesn't support
* 64-bit file access yet.
*/
if (CF_CODEC_IS_OK(ph->pdec) && ph->pdu_header.large_flag)
{
CFE_EVS_SendEvent(CF_EID_ERR_PDU_LARGE_FILE, CFE_EVS_EventType_ERROR,
"CF: pdu with large file bit received (unsupported)");
goto err_out;
}

if (CF_CODEC_IS_OK(ph->pdec) && ph->pdu_header.pdu_type == 0)
{
CF_CFDP_DecodeFileDirectiveHeader(ph->pdec, &ph->fdirective);
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 @@ -64,6 +64,7 @@
#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
#define CF_EID_ERR_PDU_LARGE_FILE 55

/* 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 @@ -255,6 +255,12 @@ void Test_CF_CFDP_RecvPh(void)
CF_CODEC_SET_DONE(ph->pdec);
UtAssert_INT32_EQ(CF_CFDP_RecvPh(UT_CFDP_CHANNEL, ph), -1);
UT_CF_AssertEventID(CF_EID_ERR_PDU_SHORT_HEADER);

/* decode error, large file bit set */
UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, NULL, NULL);
ph->pdu_header.large_flag = true;
UtAssert_INT32_EQ(CF_CFDP_RecvPh(UT_CFDP_CHANNEL, ph), -1);
UT_CF_AssertEventID(CF_EID_ERR_PDU_LARGE_FILE);
}

void Test_CF_CFDP_RecvMd(void)
Expand Down