diff --git a/unit-test/cf_codec_tests.c b/unit-test/cf_codec_tests.c index 1bb17f29..acc02b08 100644 --- a/unit-test/cf_codec_tests.c +++ b/unit-test/cf_codec_tests.c @@ -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)); @@ -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); }