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 #544, add pointer check #716

Merged
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
1 change: 1 addition & 0 deletions src/os/shared/src/osapi-sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ int32 OS_SocketSendTo(osal_id_t sock_id, const void *buffer, size_t buflen, cons
/* Check Parameters */
OS_CHECK_POINTER(buffer);
OS_CHECK_SIZE(buflen);
OS_CHECK_POINTER(RemoteAddr);

return_code = OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, LOCAL_OBJID_TYPE, sock_id, &token);
if (return_code == OS_SUCCESS)
Expand Down
10 changes: 9 additions & 1 deletion src/unit-test-coverage/shared/src/coveragetest-sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,17 @@ void Test_OS_SocketSendTo(void)
UtAssert_True(actual == expected, "OS_SocketSendTo() (%ld) == OS_SUCCESS", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_SocketSendTo(UT_OBJID_1, NULL, OSAL_SIZE_C(0), NULL);
actual = OS_SocketSendTo(UT_OBJID_1, NULL, sizeof(Buf), &Addr);
UtAssert_True(actual == expected, "OS_SocketSendTo(NULL) (%ld) == OS_INVALID_POINTER", (long)actual);

expected = OS_INVALID_POINTER;
actual = OS_SocketSendTo(UT_OBJID_1, &Buf, sizeof(Buf), NULL);
UtAssert_True(actual == expected, "OS_SocketSendTo(NULL) (%ld) == OS_INVALID_POINTER", (long)actual);

expected = OS_ERR_INVALID_SIZE;
actual = OS_SocketSendTo(UT_OBJID_1, &Buf, OSAL_SIZE_C(0), &Addr);
UtAssert_True(actual == expected, "OS_SocketSendTo(0) (%ld) == OS_ERR_INVALID_SIZE", (long)actual);

/*
* Should fail if not a datagram socket
*/
Expand Down