-
Notifications
You must be signed in to change notification settings - Fork 219
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_TimerCreate() Unterminated String #88
Comments
Imported from trac issue 65. Created by abrown4 on 2015-06-30T18:45:27, last modified: 2019-08-14T14:11:46 |
Trac comment by abrown4 on 2015-07-08 13:01:14: Similar problem found in OS_TimerGetIdByName(), line 463. |
Trac comment by abrown4 on 2015-07-08 16:45:25: Fixed vxworks ostimer.c in OS_TimerGetIdByName() and OS_TimerCreate() with the Also checked for use of the OS_MAX_API_NAME in the other OSAL's, they look correct for ostimer.c Noted the posix osapi.c does a few things a little differently internally... but it isn't immediately obvious that is is incorrect without additional inspection: |
Trac comment by abrown4 on 2015-07-08 16:59:32: Recommended documentation changes: '''OSAL-Configuration-guide.pdf''', page 10, section 2.3.2 "Configure the OSAL Parameter File": '''OSAL Library API''': In '''osconfig.h''', recommend: ''"The maxium length allowed for a object name (task, queue, etc.), including terminating null"'' Also recommend looking at: OS_MAX_PATH_LEN and OS_BUFFER_SIZE, which involve string handling. |
Trac comment by abrown4 on 2015-11-25 11:38:37: Traceability: the above commit: [changeset:37dc473] has been picked up in #135, [changeset:093359f]. However, documentation changes are still recommended. |
Trac comment by jhageman on 2019-02-28 15:01:33: [changeset:093359f] does not include the unit test update in [changeset:37dc473], was this intended or should the unit test be updated (and run in an IC branch to confirm success) prior to closure of this issue? |
Trac comment by jhageman on 2019-06-03 15:05:40: Still needs documentation and possible unit test update. |
Fix #88, Add test for name too long and update comments
…AX_PATH_LEN and OS_MAX_API_NAME includes null terminator
ostimer.c maintains a static OS_timer_table, and a char name[OS_MAX_API_NAME] is an element of each table entry.
In OS_TimerCreate(), ln 298, '''the code could leave an unterminated string in OS_timer_table[i].name'''. And it appears as though all the other code is assuming it IS a properly-terminated string. Line 243 tests:
{{{
if (strlen(timer_name) > OS_MAX_API_NAME)
...return error value
}}}
and later
{{{
strncpy(OS_timer_table[possible_tid].name, timer_name, OS_MAX_API_NAME);
}}}
copies the string with OS_MAX_API_NAME length.
But if the timer_name argument is sized exactly OS_MAX_API_NAME+1 (including the terminating null) then it'll be copied over so that there is no terminating null in the table entry name.
To fix:
{{{
if (strlen(timer_name) > OS_MAX_API_NAME-1)
}}}
The text was updated successfully, but these errors were encountered: