diff --git a/src/os/vxworks/src/os-impl-symtab.c b/src/os/vxworks/src/os-impl-symtab.c index c3018fd48..a3699f6ca 100644 --- a/src/os/vxworks/src/os-impl-symtab.c +++ b/src/os/vxworks/src/os-impl-symtab.c @@ -161,11 +161,20 @@ BOOL OS_SymTableIterator_Impl(char *name, SYM_VALUE val, SYM_TYPE type, _Vx_usr_ */ state = &OS_VxWorks_SymbolDumpState; + /* + ** Copy symbol name + */ + strncpy(symRecord.SymbolName, name, sizeof(symRecord.SymbolName) - 1); + symRecord.SymbolName[sizeof(symRecord.SymbolName) - 1] = '\0'; + + /* + ** Check to see if the max length of each symbol name has been reached + */ if (memchr(name, 0, OS_MAX_SYM_LEN) == NULL) { + symRecord.SymbolName[sizeof(symRecord.SymbolName) - 2] = '*'; OS_DEBUG("%s(): symbol name too long\n", __func__); state->StatusCode = OS_ERR_NAME_TOO_LONG; - return false; } /* @@ -183,12 +192,6 @@ BOOL OS_SymTableIterator_Impl(char *name, SYM_VALUE val, SYM_TYPE type, _Vx_usr_ return false; } - /* - ** Copy symbol name - */ - strncpy(symRecord.SymbolName, name, sizeof(symRecord.SymbolName) - 1); - symRecord.SymbolName[sizeof(symRecord.SymbolName) - 1] = 0; - /* ** Save symbol address */ diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c b/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c index 1df926e9b..b181c9147 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-symtab.c @@ -77,7 +77,7 @@ void Test_OS_SymTableIterator_Impl(void) /* Check case where entry has a name that is too long */ UT_SetDefaultReturnValue(UT_KEY(OCS_memchr), OS_ERROR); - OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut", &Data, 100, 1000), false); + OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_CallIteratorFunc("ut", &Data, 100, 1000), true); OSAPI_TEST_FUNCTION_RC(UT_SymTabTest_GetIteratorStatus(), OS_ERR_NAME_TOO_LONG); UT_ClearDefaultReturnValue(UT_KEY(OCS_memchr));