-
Notifications
You must be signed in to change notification settings - Fork 253
Description
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:
- Checkout branch fix374-2-Object-Utilities-Missing-Tests in osal
- Go to path: cFS/osal/src/tests/idmap-api-test
- Build and run with the following in the main function:
OS_ConvertToArrayIndex(bin_sem_id, NULL); - Checkout branch fix380-Add-TimeBase-Api-Functional-Tests
- Go to path: cFS/osal/src/tests/time-base-api-test
- 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