Skip to content

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

@yammajamma

Description

@yammajamma

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions