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 #2536, msg api test buffer overrun #2537

Merged
merged 1 commit into from
May 21, 2024

Conversation

jphickey
Copy link
Contributor

Checklist (Please check before submitting)

Describe the contribution
Corrects the buffer type used in the msg api tests, to be sized appropriately for either command or telemetry. When the secondary header accessor from the other type is used, it will not overrun the buffer.

Fixes #2536

Testing performed
Run functional tests

Expected behavior changes
No buffer overrun reports when using -fsanitize=address

System(s) tested on
Debian

Contributor Info - All information REQUIRED for consideration of pull request
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey added the CCB:Ready Ready for discussion at the Configuration Control Board (CCB) label Mar 26, 2024
UtAssert_INT32_EQ(CFE_MSG_SetType(CFE_MSG_PTR(cmd2), CFE_MSG_Type_Cmd), CFE_SUCCESS);
/* test generate-checksum on commands */
CFE_Assert_STATUS_STORE(CFE_MSG_ValidateChecksum(CFE_MSG_PTR(cmd), &isValid));
if (CFE_Assert_STATUS_MAY_BE(CFE_SUCCESS))

Check warning

Code scanning / CodeQL

Side effect in a Boolean expression Warning test

This Boolean expression is not side-effect free.
UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(CFE_MSG_PTR(cmd), &isValid), CFE_SUCCESS);
UtAssert_BOOL_TRUE(isValid);
}
else if (CFE_Assert_STATUS_MAY_BE(CFE_MSG_WRONG_MSG_TYPE))

Check warning

Code scanning / CodeQL

Side effect in a Boolean expression Warning test

This Boolean expression is not side-effect free.

/* test generate-checksum on telemetry */
CFE_Assert_STATUS_STORE(CFE_MSG_ValidateChecksum(CFE_MSG_PTR(tlm), &isValid));
if (CFE_Assert_STATUS_MAY_BE(CFE_SUCCESS))

Check warning

Code scanning / CodeQL

Side effect in a Boolean expression Warning test

This Boolean expression is not side-effect free.
modules/cfe_testcase/src/msg_api_test.c Fixed Show fixed Hide fixed
if (!CFE_Assert_STATUS_MAY_BE(CFE_SUCCESS))
/* Check if GetMsgTime is implemented on commands */
CFE_Assert_STATUS_STORE(CFE_MSG_GetMsgTime(CFE_MSG_PTR(cmd), &msgTime));
if (CFE_Assert_STATUS_MAY_BE(CFE_SUCCESS))

Check warning

Code scanning / CodeQL

Side effect in a Boolean expression Warning test

This Boolean expression is not side-effect free.
if (!CFE_Assert_STATUS_MAY_BE(CFE_SUCCESS))
/* Check if GetMsgTime is implemented on telemetry */
CFE_Assert_STATUS_STORE(CFE_MSG_GetMsgTime(CFE_MSG_PTR(tlm), &msgTime));
if (CFE_Assert_STATUS_MAY_BE(CFE_SUCCESS))

Check warning

Code scanning / CodeQL

Side effect in a Boolean expression Warning test

This Boolean expression is not side-effect free.
For secondary header checks, different functions may (or may not) be
implemented on commands vs telemetry.  The functional test must not
assume one or the other is implemented.  It should dynamically check
both checksum and timestamp based on the return value of the API call.
UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(CFE_MSG_PTR(tlm), &isValid), CFE_SUCCESS);
UtAssert_BOOL_TRUE(isValid);
}
else if (CFE_Assert_STATUS_MAY_BE(CFE_MSG_WRONG_MSG_TYPE))

Check warning

Code scanning / CodeQL

Side effect in a Boolean expression Warning test

This Boolean expression is not side-effect free.

CFE_Assert_STATUS_STORE(CFE_MSG_SetMsgTime(CFE_MSG_PTR(cmd2), currentTime));
if (!CFE_Assert_STATUS_MAY_BE(CFE_SUCCESS))
else if (CFE_Assert_STATUS_MAY_BE(CFE_MSG_WRONG_MSG_TYPE))

Check warning

Code scanning / CodeQL

Side effect in a Boolean expression Warning test

This Boolean expression is not side-effect free.
UtAssert_INT32_EQ(CFE_MSG_GetMsgTime(CFE_MSG_PTR(tlm), &msgTime), CFE_SUCCESS);
UtAssert_UINT32_EQ(CFE_TIME_Compare(msgTime, currentTime), CFE_TIME_EQUAL);
}
else if (CFE_Assert_STATUS_MAY_BE(CFE_MSG_WRONG_MSG_TYPE))

Check warning

Code scanning / CodeQL

Side effect in a Boolean expression Warning test

This Boolean expression is not side-effect free.
@jphickey
Copy link
Contributor Author

Should be ready now. This now has two separate buffers (cmd and tlm) and allows either operation (checksum, timestamp) to independently work or not work on either buffer.

@jphickey jphickey requested a review from skliper April 18, 2024 15:43
@dzbaker dzbaker added CCB:Approved Indicates code review and approval by community CCB and removed CCB:Ready Ready for discussion at the Configuration Control Board (CCB) labels Apr 18, 2024
dzbaker added a commit that referenced this pull request May 6, 2024
dzbaker added a commit to nasa/cFS that referenced this pull request May 6, 2024
*Combines:*

cFE equuleus-rc1+dev141
osal equuleus-rc1+dev66
PSP equuleus-rc1+dev42

**Includes:**

*cFS*
- #751
- #762

*cFE*
- nasa/cFE#2537
- nasa/cFE#2381
- nasa/cFE#2551

*osal*
- nasa/osal#1460

*PSP*
- nasa/PSP#430

Co-authored by: Justin Figueroa <[email protected]>
Co-authored by: Joseph Hickey <[email protected]>
@dzbaker dzbaker mentioned this pull request May 6, 2024
2 tasks
dzbaker added a commit to nasa/cFS that referenced this pull request May 21, 2024
*Combines:*

cFE equuleus-rc1+dev137
osal equuleus-rc1+dev66
PSP equuleus-rc1+dev42
to_lab equuleus-rc1+dev56

**Includes:**

*cFS*
- #751
- #762

*cFE*
- nasa/cFE#2537
- nasa/cFE#2525

*osal*
- nasa/osal#1460

*PSP*
- nasa/PSP#430

*to_lab*
- nasa/to_lab#198

Co-authored by: Justin Figueroa <[email protected]>
Co-authored by: Joseph Hickey <[email protected]>
Co-authored by: Cody Martin <[email protected]>
@dzbaker dzbaker merged commit 19a01d2 into nasa:main May 21, 2024
22 checks passed
dzbaker added a commit to nasa/cFS that referenced this pull request May 21, 2024
*Combines:*

cFE equuleus-rc1+dev137
osal equuleus-rc1+dev66
PSP equuleus-rc1+dev42
to_lab equuleus-rc1+dev56

**Includes:**

*cFS*
- #751
- #762

*cFE*
- nasa/cFE#2537
- nasa/cFE#2525

*osal*
- nasa/osal#1460

*PSP*
- nasa/PSP#430

*to_lab*
- nasa/to_lab#198

Co-authored by: Justin Figueroa <[email protected]>
Co-authored by: Joseph Hickey <[email protected]>
Co-authored by: Cody Martin <[email protected]>
Co-authored by: Dan Knutsen <[email protected]>
@jphickey jphickey deleted the fix-2536-msgapi-buffer branch May 29, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CCB:Approved Indicates code review and approval by community CCB
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improper stack object access in the msg api functional test
3 participants