Closed jphickey closed 2 years ago
Imported comment by internal user on Tue Nov 16 19:07:44 2021
Another example/form of this same issue appears in Test_CF_CFDP_R2_GapCompute_WhenGiven_c_size_IsGreaterThan_0_Increment_gap_counter, where it has:
pdu_nak_t dummy_nak;
followed by:
dummy_args.ph = (pdu_header_t*)&dummy_nak;
The case to (pdu_header_t*) here is not valid, because pdu_nak_t is an extension of pdu_header_t, not a replacement of it.
A more correct way to declare the buffer would be:
struct
{ pdu_header_t ph; pdu_nak_t nak; } dummy;
And then simply take the address of the ph and nak members, respectively.
This issue was imported from the GSFC issue tracking system
Imported from: [GSFCCFS-1782] CF - Incorrect cast in test functions Originally submitted by: Hickey, Joseph P. (GSFC-582.0)[VANTAGE SYSTEMS INC] on Tue Nov 16 17:11:06 2021
Original Description: Some CF test funtions incorrectly cast the pdu_header_t as a different type of header, for example inside 'Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Returns_false_But_fdh_directive_code_IsNot_PDU_METADATA_SendEventAnd_Increment_recv_error' it does this:
((pdu_file_directive_header_t*)&dummy_msg.pdu_r_msg.ph)->directive_code = Any_file_directive_t_Except(PDU_METADATA);
The problem here is that the pdu_file_directive_header_t should _follow_ the standard pdu_header_t (ph), as it is an extension of this header, it does not replace this header. As a result this is not writing the value in the location expected.