Skip to content

Commit

Permalink
Fix #277, added lcov test, now 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
alanc-gsfc committed Aug 11, 2022
1 parent 7786054 commit bf02b07
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions unit-test/cf_codec_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,8 @@ void Test_CF_CFDP_DecodeHeader(void)
CF_Logical_PduHeader_t out;
int32 ret_val;
const uint8 bytes[] = {0x3c, 0x01, 0x02, 0x00, 0x44, 0x55, 0x66};
const uint8 bad_input[] = {0x3c, 0x01, 0x02, 0x77, 0x44, 0x55, 0x66};
const uint8 bad_eid[] = {0x3c, 0x01, 0x02, 0x73, 0x44, 0x55, 0x66};
const uint8 bad_tsn[] = {0x3c, 0x01, 0x02, 0x37, 0x44, 0x55, 0x66};

/* fill with nonzero bytes so it is evident what was set */
memset(&out, 0xEE, sizeof(out));
Expand Down Expand Up @@ -747,13 +748,16 @@ void Test_CF_CFDP_DecodeHeader(void)
UtAssert_True(ret_val == CFE_SUCCESS, "CF_CFDP_DecodeHeader returned %d and should be 0", ret_val);

/*
* The bad input has large embedded EID/TSN lengths that would
* cause it to read beyond the end of the buffer. This is to
* verify that the decode detects the problem and does not
* read beyond the end. Note that this is now explicitly checked
* so only a check of the return value is needed.
* Check for EID that would be truncated
*/
UT_CF_SetupDecodeState(&state, bad_input, sizeof(bad_input));
UT_CF_SetupDecodeState(&state, bad_eid, sizeof(bad_eid));
ret_val = CF_CFDP_DecodeHeader(&state, &out);
UtAssert_True(ret_val == -1, "CF_CFDP_DecodeHeader returned %d and should be -1", ret_val);

/*
* Check for TSN that would be truncated
*/
UT_CF_SetupDecodeState(&state, bad_tsn, sizeof(bad_tsn));
ret_val = CF_CFDP_DecodeHeader(&state, &out);
UtAssert_True(ret_val == -1, "CF_CFDP_DecodeHeader returned %d and should be -1", ret_val);
}
Expand Down

0 comments on commit bf02b07

Please sign in to comment.