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 #445, add pointer parameter checks #715

Merged
merged 1 commit into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/os/shared/src/osapi-idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,9 @@ int32 OS_ObjectIdToArrayIndex(osal_objtype_t idtype, osal_id_t object_id, osal_i
osal_objtype_t actual_type;
int32 return_code;

/* Check Parameters */
OS_CHECK_POINTER(ArrayIndex);

obj_index = OS_ObjectIdToSerialNumber_Impl(object_id);
actual_type = OS_ObjectIdToType_Impl(object_id);

Expand Down
2 changes: 2 additions & 0 deletions src/os/shared/src/osapi-timebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ int32 OS_TimeBaseGetFreeRun(osal_id_t timebase_id, uint32 *freerun_val)
OS_timebase_internal_record_t *timebase;

/* Check parameters */
OS_CHECK_POINTER(freerun_val);

return_code = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, LOCAL_OBJID_TYPE, timebase_id, &token);
if (return_code == OS_SUCCESS)
{
Expand Down
4 changes: 4 additions & 0 deletions src/unit-test-coverage/shared/src/coveragetest-idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ void Test_OS_ObjectIdToArrayIndex(void)
expected = OS_ERR_INVALID_ID;
actual = OS_ObjectIdToArrayIndex(0xFFFF, UT_OBJID_OTHER, &local_idx);
UtAssert_True(actual == expected, "OS_ObjectIdToArrayIndex() (%ld) == OS_ERR_INVALID_ID", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, objid, NULL);
UtAssert_True(actual == expected, "OS_ObjectIdToArrayIndex() (%ld) == OS_INVALID_POINTER", (long)actual);
}

void Test_OS_ObjectIdFindByName(void)
Expand Down
4 changes: 4 additions & 0 deletions src/unit-test-coverage/shared/src/coveragetest-timebase.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ void Test_OS_TimeBaseGetFreeRun(void)
int32 actual = OS_TimeBaseGetFreeRun(UT_OBJID_1, &freerun);

UtAssert_True(actual == expected, "OS_TimeBaseGetFreeRun() (%ld) == OS_SUCCESS", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_TimeBaseGetFreeRun(UT_OBJID_1, NULL);
UtAssert_True(actual == expected, "OS_TimeBaseGetFreeRun() (%ld) == OS_INVALID_POINTER", (long)actual);
}

void Test_OS_TimeBase_CallbackThread(void)
Expand Down