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

OS_ConvertToArrayIndex and OS_TimeBaseGetFreeRun SEGFAULT When Passed in a NULL Pointer #445

Closed
yammajamma opened this issue May 5, 2020 · 1 comment · Fixed by #715 or #750
Closed
Assignees
Labels
Milestone

Comments

@yammajamma
Copy link
Contributor

yammajamma commented May 5, 2020

Describe the bug
OS_ConvertToArrayIndex and OS_TimeBaseGetFreeRun SEGFAULT when passed in a NULL pointer as the second input instead of handling the NULL pointer and returning an error.

To Reproduce
Steps to reproduce the behavior:

  1. Checkout branch fix374-2-Object-Utilities-Missing-Tests in osal
  2. Go to path: cFS/osal/src/tests/idmap-api-test
  3. Build and run with the following in the main function:
    OS_ConvertToArrayIndex(bin_sem_id, NULL);
  4. Checkout branch fix380-Add-TimeBase-Api-Functional-Tests
  5. Go to path: cFS/osal/src/tests/time-base-api-test
  6. Build and run with the following in the main function:
    OS_TimeBaseGetFreeRun(time_base_id2, NULL);

Expected behavior
OS_ConvertToArrayIndex and OS_TimeBaseGetFreeRun SEGFAULT when passed in a NULL pointer, should handle the NULL pointer and return an associated error code.

Code snips
(path: cFS/osal/src/tests/idmap-api-test)

uint32 bin_sem_id;
OS_BinSemCreate( &bin_sem_id, "BinSem", 1, 0);

actual = OS_ConvertToArrayIndex(bin_sem_id, NULL);
expected = OS_ERR_INCORRECT_OBJ_TYPE;
UtAssert_True(actual == expected , "OS_ConvertToArrayIndex() (%ld) == %ld ", (long)actual, (long)expected );

Output:
The following tests FAILED:
37 - idmap-api-test (SEGFAULT)

System observed on:
cFS Dev Server
OS: Ubuntu 18.04
Versions: OSAL 5.0.11.0

Reporter Info
Yasir Khan
NASA GSFC

@yammajamma yammajamma changed the title OS_ConvertToArrayIndex SEGFAULTs When Passed in a NULL Pointer OS_ConvertToArrayIndex and OS_TimeBaseGetFreeRun SEGFAULT When Passed in a NULL Pointer May 20, 2020
@skliper skliper added this to the 6.0.0 milestone Dec 9, 2020
@skliper
Copy link
Contributor

skliper commented Dec 9, 2020

Relates to nasa/cFE#520, would be helpful to have the run time assert to check for null pointer.

@skliper skliper added bug and removed enhancement labels Dec 9, 2020
jphickey added a commit to jphickey/osal that referenced this issue Dec 29, 2020
Add OS_CHECK_POINTER macros to OS_ConvertToArrayIndex and
OS_TimeBaseGetFreeRun.
astrogeco added a commit that referenced this issue Jan 13, 2021
jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
Fix nasa#445, create osal api guide with doxygen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants