From af34616b4f16b406620d28547d0b850842f9824c Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Tue, 12 Jan 2021 17:47:39 -0500 Subject: [PATCH] WIP Fix #1089, at tbl_UT.c --- fsw/cfe-core/unit-test/es_UT.c | 301 ++++++++++++++++++-------------- fsw/cfe-core/unit-test/evs_UT.c | 120 ++++++++----- fsw/cfe-core/unit-test/fs_UT.c | 4 +- fsw/cfe-core/unit-test/sb_UT.c | 30 ++-- 4 files changed, 258 insertions(+), 197 deletions(-) diff --git a/fsw/cfe-core/unit-test/es_UT.c b/fsw/cfe-core/unit-test/es_UT.c index 2190e3851..8803303f7 100644 --- a/fsw/cfe-core/unit-test/es_UT.c +++ b/fsw/cfe-core/unit-test/es_UT.c @@ -690,8 +690,8 @@ void TestInit(void) "CFE_APP, /cf/apps/ci.bundle, CI_task_main, CI_APP, 70, 4096, 0x0, 1; " "CFE_APP, /cf/apps/sch.bundle, SCH_TaskMain, SCH_APP, 120, 4096, 0x0, 1; " "CFE_APP, /cf/apps/to.bundle, TO_task_main, TO_APP, 74, 4096, 0x0, 1; !", - MAX_STARTUP_SCRIPT); - StartupScript[MAX_STARTUP_SCRIPT - 1] = '\0'; + sizeof(StartupScript) - 1); + StartupScript[sizeof(StartupScript) - 1] = '\0'; UT_SetReadBuffer(StartupScript, strlen(StartupScript)); /* Go through ES_Main and cover normal paths */ @@ -722,8 +722,8 @@ void TestStartupErrorPaths(void) "CFE_APP, /cf/apps/ci.bundle, CI_task_main, CI_APP, 70, 4096, 0x0, 1; " "CFE_APP, /cf/apps/sch.bundle, SCH_TaskMain, SCH_APP, 120, 4096, 0x0, 1; " "CFE_APP, /cf/apps/to.bundle, TO_task_main, TO_APP, 74, 4096, 0x0, 1; !", - MAX_STARTUP_SCRIPT); - StartupScript[MAX_STARTUP_SCRIPT - 1] = '\0'; + sizeof(StartupScript) - 1); + StartupScript[sizeof(StartupScript) - 1] = '\0'; /* Perform ES main startup with a mutex creation failure */ ES_ResetUnitTest(); @@ -1187,8 +1187,8 @@ void TestApps(void) "70, 4096, 0x0, 1; CFE_APP, /cf/apps/sch.bundle, SCH_TaskMain, " "SCH_APP, 120, 4096, 0x0, 1; CFE_APP, /cf/apps/to.bundle, " "TO_task_main, TO_APP, 74, 4096, 0x0, 1; !", - MAX_STARTUP_SCRIPT); - StartupScript[MAX_STARTUP_SCRIPT - 1] = '\0'; + sizeof(StartupScript) - 1); + StartupScript[sizeof(StartupScript) - 1] = '\0'; NumBytes = strlen(StartupScript); UT_SetReadBuffer(StartupScript, NumBytes); CFE_ES_StartApplications(CFE_PSP_RST_TYPE_PROCESSOR, @@ -1203,8 +1203,8 @@ void TestApps(void) "CFE_APP, /cf/apps/ci.bundle, CI_task_main, CI_APP, 70, 4096, 0x0, 1; " "CFE_APP, /cf/apps/sch.bundle, SCH_TaskMain, SCH_APP, 120, 4096, 0x0, 1; " "CFE_APP, /cf/apps/to.bundle, TO_task_main, TO_APP, 74, 4096, 0x0, 1; !", - MAX_STARTUP_SCRIPT); - StartupScript[MAX_STARTUP_SCRIPT - 1] = '\0'; + sizeof(StartupScript) - 1); + StartupScript[sizeof(StartupScript) - 1] = '\0'; NumBytes = strlen(StartupScript); UT_SetReadBuffer(StartupScript, NumBytes); @@ -1499,13 +1499,12 @@ void TestApps(void) /* Test a successful control action request to exit an application */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - strncpy((char *) UtAppRecPtr->StartParams.BasicInfo.FileName, - "/ram/Filename", OS_MAX_PATH_LEN); - UtAppRecPtr->StartParams.BasicInfo.FileName[OS_MAX_PATH_LEN - 1] = '\0'; - strncpy((char *) UtAppRecPtr->StartParams.BasicInfo.EntryPoint, - "NotNULL", OS_MAX_API_NAME); - UtAppRecPtr->StartParams.BasicInfo.EntryPoint[OS_MAX_API_NAME - 1] = - '\0'; + strncpy(UtAppRecPtr->StartParams.BasicInfo.FileName, + "/ram/Filename", sizeof(UtAppRecPtr->StartParams.BasicInfo.FileName) - 1); + UtAppRecPtr->StartParams.BasicInfo.FileName[sizeof(UtAppRecPtr->StartParams.BasicInfo.FileName) - 1] = '\0'; + strncpy(UtAppRecPtr->StartParams.BasicInfo.EntryPoint, + "NotNULL", sizeof(UtAppRecPtr->StartParams.BasicInfo.EntryPoint) - 1); + UtAppRecPtr->StartParams.BasicInfo.EntryPoint[sizeof(UtAppRecPtr->StartParams.BasicInfo.EntryPoint) - 1] = '\0'; UtAppRecPtr->StartParams.Priority = 255; UtAppRecPtr->StartParams.StackSize = 8192; UtAppRecPtr->StartParams.ExceptionAction = 0; @@ -1614,13 +1613,12 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - strncpy((char *) UtAppRecPtr->StartParams.BasicInfo.FileName, - "/ram/FileName", OS_MAX_PATH_LEN); - UtAppRecPtr->StartParams.BasicInfo.FileName[OS_MAX_PATH_LEN - 1] = '\0'; - strncpy((char *) UtAppRecPtr->StartParams.BasicInfo.EntryPoint, "NULL", - OS_MAX_API_NAME); - UtAppRecPtr->StartParams.BasicInfo.EntryPoint[OS_MAX_API_NAME - 1] = - '\0'; + strncpy(UtAppRecPtr->StartParams.BasicInfo.FileName, + "/ram/FileName", sizeof(UtAppRecPtr->StartParams.BasicInfo.FileName) - 1); + UtAppRecPtr->StartParams.BasicInfo.FileName[sizeof(UtAppRecPtr->StartParams.BasicInfo.FileName) - 1)] = '\0'; + strncpy(UtAppRecPtr->StartParams.BasicInfo.EntryPoint, "NULL", + sizeof(UtAppRecPtr->StartParams.BasicInfo.EntryPoint) - 1); + UtAppRecPtr->StartParams.BasicInfo.EntryPoint[sizeof(UtAppRecPtr->StartParams.BasicInfo.EntryPoint) - 1] = '\0'; UtAppRecPtr->StartParams.Priority = 255; UtAppRecPtr->StartParams.StackSize = 8192; UtAppRecPtr->StartParams.ExceptionAction = 0; @@ -1651,13 +1649,12 @@ void TestApps(void) /* Test a successful control action request to stop an application */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - strncpy((char *) UtAppRecPtr->StartParams.BasicInfo.FileName, - "/ram/FileName", OS_MAX_PATH_LEN); - UtAppRecPtr->StartParams.BasicInfo.FileName[OS_MAX_PATH_LEN - 1] = '\0'; - strncpy((char *) UtAppRecPtr->StartParams.BasicInfo.EntryPoint, "NULL", - OS_MAX_API_NAME); - UtAppRecPtr->StartParams.BasicInfo.EntryPoint[OS_MAX_API_NAME - 1] = - '\0'; + strncpy(UtAppRecPtr->StartParams.BasicInfo.FileName, + "/ram/FileName", sizeof(UtAppRecPtr->StartParams.BasicInfo.FileName) - 1); + UtAppRecPtr->StartParams.BasicInfo.FileName[sizeof(UtAppRecPtr->StartParams.BasicInfo.FileName) - 1] = '\0'; + strncpy(UtAppRecPtr->StartParams.BasicInfo.EntryPoint, "NULL", + sizeof(UtAppRecPtr->StartParams.BasicInfo.EntryPoint) - 1); + UtAppRecPtr->StartParams.BasicInfo.EntryPoint[sizeof(UtAppRecPtr->StartParams.BasicInfo.EntryPoint) - 1] = '\0'; UtAppRecPtr->StartParams.Priority = 255; UtAppRecPtr->StartParams.StackSize = 8192; UtAppRecPtr->StartParams.ExceptionAction = 0; @@ -1673,13 +1670,12 @@ void TestApps(void) /* Test a successful control action request to restart an application */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - strncpy((char *) UtAppRecPtr->StartParams.BasicInfo.FileName, - "/ram/FileName", OS_MAX_PATH_LEN); - UtAppRecPtr->StartParams.BasicInfo.FileName[OS_MAX_PATH_LEN - 1] = '\0'; - strncpy((char *) UtAppRecPtr->StartParams.BasicInfo.EntryPoint, "NULL", - OS_MAX_API_NAME); - UtAppRecPtr->StartParams.BasicInfo.EntryPoint[OS_MAX_API_NAME - 1] = - '\0'; + strncpy(UtAppRecPtr->StartParams.BasicInfo.FileName, + "/ram/FileName", sizeof(UtAppRecPtr->StartParams.BasicInfo.FileName) - 1); + UtAppRecPtr->StartParams.BasicInfo.FileName[sizeof(UtAppRecPtr->StartParams.BasicInfo.FileName) - 1] = '\0'; + strncpy(UtAppRecPtr->StartParams.BasicInfo.EntryPoint, "NULL", + sizeof(UtAppRecPtr->StartParams.BasicInfo.EntryPoint) - 1); + UtAppRecPtr->StartParams.BasicInfo.EntryPoint[sizeof(UtAppRecPtr->StartParams.BasicInfo.EntryPoint) - 1] = '\0'; UtAppRecPtr->StartParams.Priority = 255; UtAppRecPtr->StartParams.StackSize = 8192; UtAppRecPtr->StartParams.ExceptionAction = 0; @@ -1695,13 +1691,12 @@ void TestApps(void) /* Test a successful control action request to reload an application */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - strncpy((char *) UtAppRecPtr->StartParams.BasicInfo.FileName, - "/ram/FileName", OS_MAX_PATH_LEN); - UtAppRecPtr->StartParams.BasicInfo.FileName[OS_MAX_PATH_LEN - 1] = '\0'; - strncpy((char *) UtAppRecPtr->StartParams.BasicInfo.EntryPoint, "NULL", - OS_MAX_API_NAME); - UtAppRecPtr->StartParams.BasicInfo.EntryPoint[OS_MAX_API_NAME - 1] = - '\0'; + strncpy(UtAppRecPtr->StartParams.BasicInfo.FileName, + "/ram/FileName", sizeof(UtAppRecPtr->StartParams.BasicInfo.FileName) -1); + UtAppRecPtr->StartParams.BasicInfo.FileName[sizeof(UtAppRecPtr->StartParams.BasicInfo.FileName) -1] = '\0'; + strncpy(UtAppRecPtr->StartParams.BasicInfo.EntryPoint, "NULL", + sizeof(UtAppRecPtr->StartParams.BasicInfo.EntryPoint) - 1); + UtAppRecPtr->StartParams.BasicInfo.EntryPoint[sizeof(UtAppRecPtr->StartParams.BasicInfo.EntryPoint) - 1] = '\0'; UtAppRecPtr->StartParams.Priority = 255; UtAppRecPtr->StartParams.StackSize = 8192; UtAppRecPtr->StartParams.ExceptionAction = 0; @@ -1719,13 +1714,12 @@ void TestApps(void) */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, NULL, &UtAppRecPtr, NULL); - strncpy((char *) UtAppRecPtr->StartParams.BasicInfo.FileName, - "/ram/FileName", OS_MAX_PATH_LEN); - UtAppRecPtr->StartParams.BasicInfo.FileName[OS_MAX_PATH_LEN - 1] = '\0'; - strncpy((char *) UtAppRecPtr->StartParams.BasicInfo.EntryPoint, "NULL", - OS_MAX_API_NAME); - UtAppRecPtr->StartParams.BasicInfo.EntryPoint[OS_MAX_API_NAME - 1] = - '\0'; + strncpy(UtAppRecPtr->StartParams.BasicInfo.FileName, + "/ram/FileName", sizeof(UtAppRecPtr->StartParams.BasicInfo.FileName) - 1); + UtAppRecPtr->StartParams.BasicInfo.FileName[sizeof(UtAppRecPtr->StartParams.BasicInfo.FileName) - 1] = '\0'; + strncpy(UtAppRecPtr->StartParams.BasicInfo.EntryPoint, "NULL", + sizeof(UtAppRecPtr->StartParams.BasicInfo.EntryPoint) - 1); + UtAppRecPtr->StartParams.BasicInfo.EntryPoint[sizeof(UtAppRecPtr->StartParams.BasicInfo.EntryPoint) - 1] = '\0'; UtAppRecPtr->StartParams.Priority = 255; UtAppRecPtr->StartParams.StackSize = 8192; UtAppRecPtr->StartParams.ExceptionAction = 0; @@ -2864,12 +2858,15 @@ void TestTask(void) /* Test successful app create */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppFileName, "filename", - sizeof(CmdBuf.StartAppCmd.Payload.AppFileName)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", - sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint)); + strncpy(CmdBuf.StartAppCmd.Payload.AppFileName, "filename", + sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1); + CmdBuf.StartAppCmd.Payload.AppFileName[sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1] = '\0'; + strncpy(CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", + sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1); + CmdBuf.StartAppCmd.Payload.AppEntryPoint[sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1] = '\0'; memset(CmdBuf.StartAppCmd.Payload.Application, 'x', - sizeof(CmdBuf.StartAppCmd.Payload.Application)); + sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1); + CmdBuf.StartAppCmd.Payload.Application[sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1] = '\0'; CmdBuf.StartAppCmd.Payload.Priority = 160; CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(8192); CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; @@ -2893,12 +2890,15 @@ void TestTask(void) /* Test app create with the file name too short */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppFileName, "123", - sizeof(CmdBuf.StartAppCmd.Payload.AppFileName)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", - sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.Application, "appName", - sizeof(CmdBuf.StartAppCmd.Payload.Application)); + strncpy(CmdBuf.StartAppCmd.Payload.AppFileName, "123", + sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1); + CmdBuf.StartAppCmd.Payload.AppFileName[sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1] = '\0'; + strncpy(CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", + sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1); + CmdBuf.StartAppCmd.Payload.AppEntryPoint[sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1] = '\0'; + strncpy(CmdBuf.StartAppCmd.Payload.Application, "appName", + sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1); + CmdBuf.StartAppCmd.Payload.Application[sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1] = '\0'; CmdBuf.StartAppCmd.Payload.Priority = 160; CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(12096); CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; @@ -2912,12 +2912,13 @@ void TestTask(void) /* Test app create with a null application entry point */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppFileName, "filename", - sizeof(CmdBuf.StartAppCmd.Payload.AppFileName)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppEntryPoint, "", - sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.Application, "appName", - sizeof(CmdBuf.StartAppCmd.Payload.Application)); + strncpy(CmdBuf.StartAppCmd.Payload.AppFileName, "filename", + sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1); + CmdBuf.StartAppCmd.Payload.AppFileName[sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1] = '\0'; + CmdBuf.StartAppCmd.Payload.AppEntryPoint[0] = '\0'; + strncpy(CmdBuf.StartAppCmd.Payload.Application, "appName", + sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1); + CmdBuf.StartAppCmd.Payload.Application[sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1] = '\0'; CmdBuf.StartAppCmd.Payload.Priority = 160; CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(12096); CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; @@ -2931,12 +2932,13 @@ void TestTask(void) /* Test app create with a null application name */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppFileName, "filename", - sizeof(CmdBuf.StartAppCmd.Payload.AppFileName)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", - sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.Application, "", - sizeof(CmdBuf.StartAppCmd.Payload.Application)); + strncpy(CmdBuf.StartAppCmd.Payload.AppFileName, "filename", + sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1); + CmdBuf.StartAppCmd.Payload.AppFileName[sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1] = '\0'; + strncpy(CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", + sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1); + CmdBuf.StartAppCmd.Payload.AppEntryPoint[sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1] = '\0'; + CmdBuf.StartAppCmd.Payload.Application[0] = '\0'; CmdBuf.StartAppCmd.Payload.Priority = 160; CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(12096); CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; @@ -2950,12 +2952,15 @@ void TestTask(void) /* Test app create with with an invalid exception action */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppFileName, "filename", - sizeof(CmdBuf.StartAppCmd.Payload.AppFileName)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", - sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.Application, "appName", - sizeof(CmdBuf.StartAppCmd.Payload.Application)); + strncpy(CmdBuf.StartAppCmd.Payload.AppFileName, "filename", + sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1); + CmdBuf.StartAppCmd.Payload.AppFileName[sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1] = '\0'; + strncpy(CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", + sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1); + CmdBuf.StartAppCmd.Payload.AppEntryPoint[sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1] = '\0'; + strncpy(CmdBuf.StartAppCmd.Payload.Application, "appName", + sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1); + CmdBuf.StartAppCmd.Payload.Application[sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1] = '\0'; CmdBuf.StartAppCmd.Payload.Priority = 160; CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(12096); CmdBuf.StartAppCmd.Payload.ExceptionAction = 255; @@ -2969,12 +2974,15 @@ void TestTask(void) /* Test app create with a default stack size */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppFileName, "filename", - sizeof(CmdBuf.StartAppCmd.Payload.AppFileName)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", - sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.Application, "appName", - sizeof(CmdBuf.StartAppCmd.Payload.Application)); + strncpy(CmdBuf.StartAppCmd.Payload.AppFileName, "filename", + sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1); + CmdBuf.StartAppCmd.Payload.AppFileName[sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1] = '\0'; + strncpy(CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", + sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1); + CmdBuf.StartAppCmd.Payload.AppEntryPoint[sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1] = '\0'; + strncpy(CmdBuf.StartAppCmd.Payload.Application, "appName", + sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1); + CmdBuf.StartAppCmd.Payload.Application[sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1] = '\0'; CmdBuf.StartAppCmd.Payload.Priority = 160; CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(0); CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; @@ -2988,12 +2996,15 @@ void TestTask(void) /* Test app create with a bad priority */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppFileName, "filename", - sizeof(CmdBuf.StartAppCmd.Payload.AppFileName)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", - sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.Application, "appName", - sizeof(CmdBuf.StartAppCmd.Payload.Application)); + strncpy(CmdBuf.StartAppCmd.Payload.AppFileName, "filename", + sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1); + CmdBuf.StartAppCmd.Payload.AppFileName[sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1] = '\0'; + strncpy(CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", + sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1); + CmdBuf.StartAppCmd.Payload.AppEntryPoint[sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1] = '\0'; + strncpy(CmdBuf.StartAppCmd.Payload.Application, "appName", + sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1); + CmdBuf.StartAppCmd.Payload.Application[sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1] = '\0'; CmdBuf.StartAppCmd.Payload.Priority = 1000; CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(12096); CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_RESTART_APP; @@ -3007,8 +3018,9 @@ void TestTask(void) /* Test successful app stop */ ES_ResetUnitTest(); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, "CFE_ES", NULL, NULL); - strncpy((char *) CmdBuf.StopAppCmd.Payload.Application, "CFE_ES", - sizeof(CmdBuf.StopAppCmd.Payload.Application)); + strncpy(CmdBuf.StopAppCmd.Payload.Application, "CFE_ES", + sizeof(CmdBuf.StopAppCmd.Payload.Application) - 1); + CmdBuf.StopAppCmd.Payload.Application[sizeof(CmdBuf.StopAppCmd.Payload.Application) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.StopAppCmd), UT_TPID_CFE_ES_CMD_STOP_APP_CC); UT_Report(__FILE__, __LINE__, @@ -3029,8 +3041,9 @@ void TestTask(void) /* Test app stop with a bad app name */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.StopAppCmd.Payload.Application, "BAD_APP_NAME", - sizeof(CmdBuf.StopAppCmd.Payload.Application)); + strncpy(CmdBuf.StopAppCmd.Payload.Application, "BAD_APP_NAME", + sizeof(CmdBuf.StopAppCmd.Payload.Application) - 1); + CmdBuf.StopAppCmd.Payload.Application[sizeof(CmdBuf.StopAppCmd.Payload.Application) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.StopAppCmd), UT_TPID_CFE_ES_CMD_STOP_APP_CC); UT_Report(__FILE__, __LINE__, @@ -3042,8 +3055,9 @@ void TestTask(void) ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, "CFE_ES", NULL, NULL); - strncpy((char *) CmdBuf.RestartAppCmd.Payload.Application, "CFE_ES", - sizeof(CmdBuf.RestartAppCmd.Payload.Application)); + strncpy(CmdBuf.RestartAppCmd.Payload.Application, "CFE_ES", + sizeof(CmdBuf.RestartAppCmd.Payload.Application) - 1); + CmdBuf.RestartAppCmd.Payload.Application[sizeof(CmdBuf.RestartAppCmd.Payload.Application) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.RestartAppCmd), UT_TPID_CFE_ES_CMD_RESTART_APP_CC); UT_Report(__FILE__, __LINE__, @@ -3054,8 +3068,9 @@ void TestTask(void) /* Test app restart with a bad app name */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.RestartAppCmd.Payload.Application, "BAD_APP_NAME", - sizeof(CmdBuf.RestartAppCmd.Payload.Application)); + strncpy(CmdBuf.RestartAppCmd.Payload.Application, "BAD_APP_NAME", + sizeof(CmdBuf.RestartAppCmd.Payload.Application) - 1); + CmdBuf.RestartAppCmd.Payload.Application[sizeof(CmdBuf.RestartAppCmd.Payload.Application) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.RestartAppCmd), UT_TPID_CFE_ES_CMD_RESTART_APP_CC); UT_Report(__FILE__, __LINE__, @@ -3067,8 +3082,9 @@ void TestTask(void) ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_WAITING, "CFE_ES", NULL, NULL); - strncpy((char *) CmdBuf.RestartAppCmd.Payload.Application, "CFE_ES", - sizeof(CmdBuf.RestartAppCmd.Payload.Application)); + strncpy(CmdBuf.RestartAppCmd.Payload.Application, "CFE_ES", + sizeof(CmdBuf.RestartAppCmd.Payload.Application) - 1); + CmdBuf.RestartAppCmd.Payload.Application[sizeof(CmdBuf.RestartAppCmd.Payload.Application) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.RestartAppCmd), UT_TPID_CFE_ES_CMD_RESTART_APP_CC); UT_Report(__FILE__, __LINE__, @@ -3080,10 +3096,12 @@ void TestTask(void) ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppState_RUNNING, "CFE_ES", NULL, NULL); - strncpy((char *) CmdBuf.ReloadAppCmd.Payload.AppFileName, "New_Name", - sizeof(CmdBuf.ReloadAppCmd.Payload.AppFileName)); - strncpy((char *) CmdBuf.ReloadAppCmd.Payload.Application, "CFE_ES", - sizeof(CmdBuf.ReloadAppCmd.Payload.Application)); + strncpy(CmdBuf.ReloadAppCmd.Payload.AppFileName, "New_Name", + sizeof(CmdBuf.ReloadAppCmd.Payload.AppFileName) - 1); + CmdBuf.ReloadAppCmd.Payload.AppFileName[sizeof(CmdBuf.ReloadAppCmd.Payload.AppFileName) - 1] = '\0'; + strncpy(CmdBuf.ReloadAppCmd.Payload.Application, "CFE_ES", + sizeof(CmdBuf.ReloadAppCmd.Payload.Application) - 1); + CmdBuf.ReloadAppCmd.Payload.Application[sizeof(CmdBuf.ReloadAppCmd.Payload.Application) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.ReloadAppCmd), UT_TPID_CFE_ES_CMD_RELOAD_APP_CC); UT_Report(__FILE__, __LINE__, @@ -3094,8 +3112,9 @@ void TestTask(void) /* Test app reload with a bad app name */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.ReloadAppCmd.Payload.Application, "BAD_APP_NAME", - sizeof(CmdBuf.ReloadAppCmd.Payload.Application)); + strncpy(CmdBuf.ReloadAppCmd.Payload.Application, "BAD_APP_NAME", + sizeof(CmdBuf.ReloadAppCmd.Payload.Application) - 1); + CmdBuf.ReloadAppCmd.Payload.Application[sizeof(CmdBuf.ReloadAppCmd.Payload.Application) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.ReloadAppCmd), UT_TPID_CFE_ES_CMD_RELOAD_APP_CC); UT_Report(__FILE__, __LINE__, @@ -3107,8 +3126,9 @@ void TestTask(void) ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_WAITING, "CFE_ES", NULL, NULL); - strncpy((char *) CmdBuf.ReloadAppCmd.Payload.Application, "CFE_ES", - sizeof(CmdBuf.ReloadAppCmd.Payload.Application)); + strncpy(CmdBuf.ReloadAppCmd.Payload.Application, "CFE_ES", + sizeof(CmdBuf.ReloadAppCmd.Payload.Application) - 1); + CmdBuf.ReloadAppCmd.Payload.Application[sizeof(CmdBuf.ReloadAppCmd.Payload.Application) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.ReloadAppCmd), UT_TPID_CFE_ES_CMD_RELOAD_APP_CC); UT_Report(__FILE__, __LINE__, @@ -3120,8 +3140,9 @@ void TestTask(void) ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_WAITING, "CFE_ES", NULL, NULL); - strncpy((char *) CmdBuf.QueryOneCmd.Payload.Application, "CFE_ES", - sizeof(CmdBuf.QueryOneCmd.Payload.Application)); + strncpy(CmdBuf.QueryOneCmd.Payload.Application, "CFE_ES", + sizeof(CmdBuf.QueryOneCmd.Payload.Application) - 1); + CmdBuf.QueryOneCmd.Payload.Application[sizeof(CmdBuf.QueryOneCmd.Payload.Application) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.QueryOneCmd), UT_TPID_CFE_ES_CMD_QUERY_ONE_CC); UT_Report(__FILE__, __LINE__, @@ -3133,8 +3154,9 @@ void TestTask(void) ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, "CFE_ES", NULL, NULL); - strncpy((char *) CmdBuf.QueryOneCmd.Payload.Application, "CFE_ES", - sizeof(CmdBuf.QueryOneCmd.Payload.Application)); + strncpy(CmdBuf.QueryOneCmd.Payload.Application, "CFE_ES", + sizeof(CmdBuf.QueryOneCmd.Payload.Application) - 1); + CmdBuf.QueryOneCmd.Payload.Application[sizeof(CmdBuf.QueryOneCmd.Payload.Application) - 1] = '\0'; UT_SetDeferredRetcode(UT_KEY(CFE_SB_TransmitMsg), 1, -1); UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.QueryOneCmd), UT_TPID_CFE_ES_CMD_QUERY_ONE_CC); @@ -3147,8 +3169,9 @@ void TestTask(void) ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, "CFE_ES", NULL, NULL); - strncpy((char *) CmdBuf.QueryOneCmd.Payload.Application, "BAD_APP_NAME", - sizeof(CmdBuf.QueryOneCmd.Payload.Application)); + strncpy(CmdBuf.QueryOneCmd.Payload.Application, "BAD_APP_NAME", + sizeof(CmdBuf.QueryOneCmd.Payload.Application) - 1); + CmdBuf.QueryOneCmd.Payload.Application[sizeof(CmdBuf.QueryOneCmd.Payload.Application) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.QueryOneCmd), UT_TPID_CFE_ES_CMD_QUERY_ONE_CC); UT_Report(__FILE__, __LINE__, @@ -3160,8 +3183,9 @@ void TestTask(void) ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, "CFE_ES", NULL, NULL); - strncpy((char *) CmdBuf.QueryAllCmd.Payload.FileName, "AllFilename", - sizeof(CmdBuf.QueryAllCmd.Payload.FileName)); + strncpy(CmdBuf.QueryAllCmd.Payload.FileName, "AllFilename", + sizeof(CmdBuf.QueryAllCmd.Payload.FileName) - 1); + CmdBuf.QueryAllCmd.Payload.FileName[sizeof(CmdBuf.QueryAllCmd.Payload.FileName) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.QueryAllCmd), UT_TPID_CFE_ES_CMD_QUERY_ALL_CC); UT_Report(__FILE__, __LINE__, @@ -3228,8 +3252,9 @@ void TestTask(void) /* Test write of all task data to a file with write header failure */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.QueryAllTasksCmd.Payload.FileName, "filename", - sizeof(CmdBuf.QueryAllTasksCmd.Payload.FileName)); + strncpy(CmdBuf.QueryAllTasksCmd.Payload.FileName, "filename", + sizeof(CmdBuf.QueryAllTasksCmd.Payload.FileName) - 1); + CmdBuf.QueryAllTasksCmd.Payload.FileName[sizeof(CmdBuf.QueryAllTasksCmd.Payload.FileName) - 1] = '\0'; UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, -1); UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.QueryAllTasksCmd), UT_TPID_CFE_ES_CMD_QUERY_ALL_TASKS_CC); @@ -3296,8 +3321,9 @@ void TestTask(void) /* Test successful writing of the system log */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.WriteSysLogCmd.Payload.FileName, "filename", - sizeof(CmdBuf.WriteSysLogCmd.Payload.FileName)); + strncpy(CmdBuf.WriteSysLogCmd.Payload.FileName, "filename", + sizeof(CmdBuf.WriteSysLogCmd.Payload.FileName) - 1); + CmdBuf.WriteSysLogCmd.Payload.FileName[sizeof(CmdBuf.WriteSysLogCmd.Payload.FileName) - 1] = '\0'; CFE_ES_TaskData.HkPacket.Payload.SysLogEntries = 123; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.WriteSysLogCmd), UT_TPID_CFE_ES_CMD_WRITE_SYSLOG_CC); @@ -3321,8 +3347,7 @@ void TestTask(void) ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR); - strncpy((char *) CmdBuf.WriteSysLogCmd.Payload.FileName, "", - sizeof(CmdBuf.WriteSysLogCmd.Payload.FileName)); + CmdBuf.WriteSysLogCmd.Payload.FileName[0] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.WriteSysLogCmd), UT_TPID_CFE_ES_CMD_WRITE_SYSLOG_CC); UT_Report(__FILE__, __LINE__, @@ -3338,8 +3363,7 @@ void TestTask(void) sizeof(CFE_ES_ResetDataPtr->SystemLog), "0000-000-00:00:00.00000 Test Message\n"); CFE_ES_ResetDataPtr->SystemLogEndIdx = CFE_ES_ResetDataPtr->SystemLogWriteIdx; - strncpy((char *) CmdBuf.WriteSysLogCmd.Payload.FileName, "", - sizeof(CmdBuf.WriteSysLogCmd.Payload.FileName)); + CmdBuf.WriteSysLogCmd.Payload.FileName[0] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.WriteSysLogCmd), UT_TPID_CFE_ES_CMD_WRITE_SYSLOG_CC); UT_Report(__FILE__, __LINE__, @@ -3373,7 +3397,8 @@ void TestTask(void) ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); strncpy(CmdBuf.WriteERLogCmd.Payload.FileName, "filename", - sizeof(CmdBuf.WriteERLogCmd.Payload.FileName)); + sizeof(CmdBuf.WriteERLogCmd.Payload.FileName) - 1); + CmdBuf.WriteERLogCmd.Payload.FileName[sizeof(CmdBuf.WriteERLogCmd.Payload.FileName) - 1] = '\0'; CFE_ES_TaskData.BackgroundERLogDumpState.IsPending = false; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.WriteERLogCmd), UT_TPID_CFE_ES_CMD_WRITE_ER_LOG_CC); @@ -3560,7 +3585,8 @@ void TestTask(void) memset(&CmdBuf, 0, sizeof(CmdBuf)); strncpy(CmdBuf.DeleteCDSCmd.Payload.CdsName, "CFE_ES.CDS_NAME", - sizeof(CmdBuf.DeleteCDSCmd.Payload.CdsName)); + sizeof(CmdBuf.DeleteCDSCmd.Payload.CdsName) - 1); + CmdBuf.DeleteCDSCmd.Payload.CdsName[sizeof(CmdBuf.DeleteCDSCmd.Payload.CdsName) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.DeleteCDSCmd), UT_TPID_CFE_ES_CMD_DELETE_CDS_CC); UT_Report(__FILE__, __LINE__, @@ -3743,12 +3769,15 @@ void TestTask(void) */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppFileName, "filename", - sizeof(CmdBuf.StartAppCmd.Payload.AppFileName)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", - sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint)); - strncpy((char *) CmdBuf.StartAppCmd.Payload.Application, "appName", - sizeof(CmdBuf.StartAppCmd.Payload.Application)); + strncpy(CmdBuf.StartAppCmd.Payload.AppFileName, "filename", + sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1); + CmdBuf.StartAppCmd.Payload.AppFileName[sizeof(CmdBuf.StartAppCmd.Payload.AppFileName) - 1] = '\0'; + strncpy(CmdBuf.StartAppCmd.Payload.AppEntryPoint, "entrypoint", + sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1); + CmdBuf.StartAppCmd.Payload.AppEntryPoint[sizeof(CmdBuf.StartAppCmd.Payload.AppEntryPoint) - 1] = '\0'; + strncpy(CmdBuf.StartAppCmd.Payload.Application, "appName", + sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1); + CmdBuf.StartAppCmd.Payload.Application[sizeof(CmdBuf.StartAppCmd.Payload.Application) - 1] = '\0'; CmdBuf.StartAppCmd.Payload.ExceptionAction = CFE_ES_ExceptionAction_PROC_RESTART; CmdBuf.StartAppCmd.Payload.Priority = 160; CmdBuf.StartAppCmd.Payload.StackSize = CFE_ES_MEMOFFSET_C(CFE_PLATFORM_ES_DEFAULT_STACK_SIZE); @@ -3953,7 +3982,8 @@ void TestTask(void) ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, "CFE_ES", NULL, NULL); ES_UT_SetupSingleCDSRegistry("CFE_ES.CDS_NAME", ES_UT_CDS_BLOCK_SIZE, false, NULL); strncpy(CmdBuf.DumpCDSRegistryCmd.Payload.DumpFilename, "DumpFile", - sizeof(CmdBuf.DumpCDSRegistryCmd.Payload.DumpFilename)); + sizeof(CmdBuf.DumpCDSRegistryCmd.Payload.DumpFilename) - 1); + CmdBuf.DumpCDSRegistryCmd.Payload.DumpFilename[sizeof(CmdBuf.DumpCDSRegistryCmd.Payload.DumpFilename) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.DumpCDSRegistryCmd), UT_TPID_CFE_ES_CMD_DUMP_CDS_REGISTRY_CC); UT_Report(__FILE__, __LINE__, @@ -4100,7 +4130,8 @@ void TestPerf(void) memset(&CFE_ES_TaskData.BackgroundPerfDumpState, 0, sizeof(CFE_ES_TaskData.BackgroundPerfDumpState)); strncpy(CmdBuf.PerfStopCmd.Payload.DataFileName, "filename", - sizeof(CmdBuf.PerfStopCmd.Payload.DataFileName)); + sizeof(CmdBuf.PerfStopCmd.Payload.DataFileName) - 1); + CmdBuf.PerfStopCmd.Payload.DataFileName[sizeof(CmdBuf.PerfStopCmd.Payload.DataFileName) - 1] = '\0'; UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.PerfStopCmd), UT_TPID_CFE_ES_CMD_STOP_PERF_DATA_CC); UT_Report(__FILE__, __LINE__, diff --git a/fsw/cfe-core/unit-test/evs_UT.c b/fsw/cfe-core/unit-test/evs_UT.c index b68e24efe..d22ae427b 100644 --- a/fsw/cfe-core/unit-test/evs_UT.c +++ b/fsw/cfe-core/unit-test/evs_UT.c @@ -303,8 +303,9 @@ void Test_Init(void) UtPrintf("Begin Test Init"); - strncpy((char *) appbitcmd.Payload.AppName, "ut_cfe_evs", - sizeof(appbitcmd.Payload.AppName)); + strncpy(appbitcmd.Payload.AppName, "ut_cfe_evs", + sizeof(appbitcmd.Payload.AppName) - 1); + appbitcmd.Payload.AppName[sizeof(appbitcmd.Payload.AppName) - 1] = '\0'; /* Test successful early initialization of the cFE EVS */ UT_InitData(); @@ -941,8 +942,9 @@ void Test_Format(void) /* Enable DEBUG message output */ UT_InitData(); - strncpy((char *) appbitcmd.Payload.AppName, "ut_cfe_evs", - sizeof(appbitcmd.Payload.AppName)); + strncpy(appbitcmd.Payload.AppName, "ut_cfe_evs", + sizeof(appbitcmd.Payload.AppName) - 1); + appbitcmd.Payload.AppName[sizeof(appbitcmd.Payload.AppName) - 1] = '\0'; modecmd.Payload.MsgFormat = CFE_EVS_MsgFormat_LONG; appbitcmd.Payload.BitMask = CFE_EVS_DEBUG_BIT | CFE_EVS_INFORMATION_BIT | CFE_EVS_ERROR_BIT | CFE_EVS_CRITICAL_BIT; @@ -1406,8 +1408,9 @@ void Test_Logging(void) */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_SUCCESS); - strncpy((char *) CmdBuf.logfilecmd.Payload.LogFilename, "LogFile", - sizeof(CmdBuf.logfilecmd.Payload.LogFilename)); + strncpy(CmdBuf.logfilecmd.Payload.LogFilename, "LogFile", + sizeof(CmdBuf.logfilecmd.Payload.LogFilename) - 1); + CmdBuf.logfilecmd.Payload.LogFilename[sizeof(CmdBuf.logfilecmd.Payload.LogFilename) - 1] = '\0'; UT_Report(__FILE__, __LINE__, CFE_EVS_WriteLogDataFileCmd(&CmdBuf.logfilecmd) == CFE_SUCCESS, "CFE_EVS_WriteLogDataFileCmd", @@ -1444,8 +1447,9 @@ void Test_WriteApp(void) /* Enable DEBUG message output */ UT_InitData(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - strncpy((char *) CmdBuf.appbitcmd.Payload.AppName, "ut_cfe_evs", - sizeof(CmdBuf.appbitcmd.Payload.AppName)); + strncpy(CmdBuf.appbitcmd.Payload.AppName, "ut_cfe_evs", + sizeof(CmdBuf.appbitcmd.Payload.AppName) - 1); + CmdBuf.appbitcmd.Payload.AppName[sizeof(CmdBuf.appbitcmd.Payload.AppName) - 1] = '\0'; CmdBuf.appbitcmd.Payload.BitMask = CFE_EVS_DEBUG_BIT | CFE_EVS_INFORMATION_BIT | CFE_EVS_ERROR_BIT | CFE_EVS_CRITICAL_BIT; UT_EVS_DoDispatchCheckEvents(&CmdBuf.appbitcmd, sizeof(CmdBuf.appbitcmd), @@ -1470,8 +1474,9 @@ void Test_WriteApp(void) * file name */ UT_InitData(); - strncpy((char *) CmdBuf.AppDataCmd.Payload.AppDataFilename, "ut_cfe_evs", - sizeof(CmdBuf.AppDataCmd.Payload.AppDataFilename)); + strncpy(CmdBuf.AppDataCmd.Payload.AppDataFilename, "ut_cfe_evs", + sizeof(CmdBuf.AppDataCmd.Payload.AppDataFilename) - 1); + CmdBuf.AppDataCmd.Payload.AppDataFilename[sizeof(CmdBuf.AppDataCmd.Payload.AppDataFilename) - 1] = '\0'; UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR); UT_EVS_DoDispatchCheckEvents(&CmdBuf.AppDataCmd, sizeof(CmdBuf.AppDataCmd), UT_TPID_CFE_EVS_CMD_WRITE_APP_DATA_FILE_CC, @@ -1507,8 +1512,9 @@ void Test_WriteApp(void) * file name */ UT_InitData(); - strncpy((char *) CmdBuf.AppDataCmd.Payload.AppDataFilename, "AppDataFileName", - sizeof(CmdBuf.AppDataCmd.Payload.AppDataFilename)); + strncpy(CmdBuf.AppDataCmd.Payload.AppDataFilename, "AppDataFileName", + sizeof(CmdBuf.AppDataCmd.Payload.AppDataFilename) - 1); + CmdBuf.AppDataCmd.Payload.AppDataFilename[sizeof(CmdBuf.AppDataCmd.Payload.AppDataFilename) - 1] = '\0'; UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR); UT_EVS_DoDispatchCheckEvents(&CmdBuf.AppDataCmd, sizeof(CmdBuf.AppDataCmd), UT_TPID_CFE_EVS_CMD_WRITE_APP_DATA_FILE_CC, @@ -1551,14 +1557,18 @@ void Test_BadAppCmd(void) appmaskcmd.Payload.EventID = 0; appcmdcmd.Payload.EventID = 0; - strncpy((char *) appbitcmd.Payload.AppName, "unknown_name", - sizeof(appbitcmd.Payload.AppName)); - strncpy((char *) appnamecmd.Payload.AppName, "unknown_name", - sizeof(appnamecmd.Payload.AppName)); - strncpy((char *) appmaskcmd.Payload.AppName, "unknown_name", - sizeof(appmaskcmd.Payload.AppName)); - strncpy((char *) appcmdcmd.Payload.AppName, "unknown_name", - sizeof(appcmdcmd.Payload.AppName)); + strncpy(appbitcmd.Payload.AppName, "unknown_name", + sizeof(appbitcmd.Payload.AppName) - 1); + appbitcmd.Payload.AppName[sizeof(appbitcmd.Payload.AppName) - 1] = '\0'; + strncpy(appnamecmd.Payload.AppName, "unknown_name", + sizeof(appnamecmd.Payload.AppName) - 1); + appnamecmd.Payload.AppName[sizeof(appnamecmd.Payload.AppName) - 1] = '\0'; + strncpy(appmaskcmd.Payload.AppName, "unknown_name", + sizeof(appmaskcmd.Payload.AppName) - 1); + appmaskcmd.Payload.AppName[sizeof(appmaskcmd.Payload.AppName) - 1] = '\0'; + strncpy(appcmdcmd.Payload.AppName, "unknown_name", + sizeof(appcmdcmd.Payload.AppName) - 1); + appcmdcmd.Payload.AppName[sizeof(appcmdcmd.Payload.AppName) - 1] = '\0'; /* Test disabling application event types with an unknown application ID */ UT_SetDefaultReturnValue(UT_KEY(CFE_ES_GetAppIDByName), CFE_ES_ERR_NAME_NOT_FOUND); @@ -1676,14 +1686,18 @@ void Test_BadAppCmd(void) /* Test disabling application event types with an illegal application ID */ UT_InitData(); - strncpy((char *) appbitcmd.Payload.AppName, "illegal_id", - sizeof(appbitcmd.Payload.AppName)); - strncpy((char *) appnamecmd.Payload.AppName, "illegal_id", - sizeof(appnamecmd.Payload.AppName)); - strncpy((char *) appmaskcmd.Payload.AppName, "illegal_id", - sizeof(appmaskcmd.Payload.AppName)); - strncpy((char *) appcmdcmd.Payload.AppName, "illegal_id", - sizeof(appcmdcmd.Payload.AppName)); + strncpy(appbitcmd.Payload.AppName, "illegal_id", + sizeof(appbitcmd.Payload.AppName) - 1); + appbitcmd.Payload.AppName[sizeof(appbitcmd.Payload.AppName) - 1] = '\0'; + strncpy(appnamecmd.Payload.AppName, "illegal_id", + sizeof(appnamecmd.Payload.AppName) - 1); + appnamecmd.Payload.AppName[sizeof(appnamecmd.Payload.AppName) - 1] = '\0'; + strncpy(appmaskcmd.Payload.AppName, "illegal_id", + sizeof(appmaskcmd.Payload.AppName) - 1); + appmaskcmd.Payload.AppName[sizeof(appmaskcmd.Payload.AppName) - 1] = '\0'; + strncpy(appcmdcmd.Payload.AppName, "illegal_id", + sizeof(appcmdcmd.Payload.AppName) - 1); + appcmdcmd.Payload.AppName[sizeof(appcmdcmd.Payload.AppName) - 1] = '\0'; /* * Generate an illegal AppID error when looking up the UT appID (first call), @@ -1807,14 +1821,18 @@ void Test_BadAppCmd(void) UT_InitData(); TestAppIndex = 2; UT_SetDataBuffer(UT_KEY(CFE_ES_AppID_ToIndex), &TestAppIndex, sizeof(TestAppIndex), false); - strncpy((char *) appbitcmd.Payload.AppName, "unregistered_app", - sizeof(appbitcmd.Payload.AppName)); - strncpy((char *) appnamecmd.Payload.AppName, "unregistered_app", - sizeof(appnamecmd.Payload.AppName)); - strncpy((char *) appmaskcmd.Payload.AppName, "unregistered_app", - sizeof(appmaskcmd.Payload.AppName)); - strncpy((char *) appcmdcmd.Payload.AppName, "unregistered_app", - sizeof(appcmdcmd.Payload.AppName)); + strncpy(appbitcmd.Payload.AppName, "unregistered_app", + sizeof(appbitcmd.Payload.AppName) - 1); + appbitcmd.Payload.AppName[sizeof(appbitcmd.Payload.AppName) - 1] = '\0'; + strncpy(appnamecmd.Payload.AppName, "unregistered_app", + sizeof(appnamecmd.Payload.AppName) - 1); + appnamecmd.Payload.AppName[sizeof(appnamecmd.Payload.AppName) - 1] = '\0'; + strncpy(appmaskcmd.Payload.AppName, "unregistered_app", + sizeof(appmaskcmd.Payload.AppName) - 1); + appmaskcmd.Payload.AppName[sizeof(appmaskcmd.Payload.AppName) - 1] = '\0'; + strncpy(appcmdcmd.Payload.AppName, "unregistered_app", + sizeof(appcmdcmd.Payload.AppName) - 1); + appcmdcmd.Payload.AppName[sizeof(appcmdcmd.Payload.AppName) - 1] = '\0'; UT_EVS_DoDispatchCheckEvents(&appbitcmd, sizeof(appbitcmd), UT_TPID_CFE_EVS_CMD_DISABLE_APP_EVENT_TYPE_CC, &UT_EVS_EventBuf); @@ -1951,10 +1969,12 @@ void Test_EventCmd(void) UT_InitData(); /* Run the next series of tests with valid, registered application name */ - strncpy((char *) appbitcmd.Payload.AppName, "ut_cfe_evs", - sizeof(appbitcmd.Payload.AppName)); - strncpy((char *) appnamecmd.Payload.AppName, "ut_cfe_evs", - sizeof(appnamecmd.Payload.AppName)); + strncpy(appbitcmd.Payload.AppName, "ut_cfe_evs", + sizeof(appbitcmd.Payload.AppName) - 1); + appbitcmd.Payload.AppName[sizeof(appbitcmd.Payload.AppName) - 1] = '\0'; + strncpy(appnamecmd.Payload.AppName, "ut_cfe_evs", + sizeof(appnamecmd.Payload.AppName) - 1); + appnamecmd.Payload.AppName[sizeof(appnamecmd.Payload.AppName) - 1] = '\0'; /* Test disabling of all events */ appbitcmd.Payload.BitMask = CFE_EVS_DEBUG_BIT | CFE_EVS_INFORMATION_BIT | @@ -2197,14 +2217,18 @@ void Test_FilterCmd(void) appcmdcmd.Payload.EventID = 0; /* Run the next series of tests with valid, registered application name */ - strncpy((char *) appnamecmd.Payload.AppName, "ut_cfe_evs", - sizeof(appnamecmd.Payload.AppName)); - strncpy((char *) appmaskcmd.Payload.AppName, "ut_cfe_evs", - sizeof(appmaskcmd.Payload.AppName)); - strncpy((char *) appcmdcmd.Payload.AppName, "ut_cfe_evs", - sizeof(appcmdcmd.Payload.AppName)); - strncpy((char *) appbitcmd.Payload.AppName, "ut_cfe_evs", - sizeof(appbitcmd.Payload.AppName)); + strncpy(appnamecmd.Payload.AppName, "ut_cfe_evs", + sizeof(appnamecmd.Payload.AppName) - 1); + appnamecmd.Payload.AppName[sizeof(appnamecmd.Payload.AppName) - 1] = '\0'; + strncpy(appmaskcmd.Payload.AppName, "ut_cfe_evs", + sizeof(appmaskcmd.Payload.AppName) - 1); + appmaskcmd.Payload.AppName[sizeof(appmaskcmd.Payload.AppName) - 1] = '\0'; + strncpy(appcmdcmd.Payload.AppName, "ut_cfe_evs", + sizeof(appcmdcmd.Payload.AppName) - 1); + appcmdcmd.Payload.AppName[sizeof(appcmdcmd.Payload.AppName) - 1] = '\0'; + strncpy(appbitcmd.Payload.AppName, "ut_cfe_evs", + sizeof(appbitcmd.Payload.AppName) - 1); + appbitcmd.Payload.AppName[sizeof(appbitcmd.Payload.AppName) - 1] = '\0'; /* Enable all application event message output */ appbitcmd.Payload.BitMask = CFE_EVS_DEBUG_BIT | CFE_EVS_INFORMATION_BIT | diff --git a/fsw/cfe-core/unit-test/fs_UT.c b/fsw/cfe-core/unit-test/fs_UT.c index a1b6f5c48..4b569cb19 100644 --- a/fsw/cfe-core/unit-test/fs_UT.c +++ b/fsw/cfe-core/unit-test/fs_UT.c @@ -247,8 +247,8 @@ void Test_CFE_FS_ExtractFileNameFromPath(void) * missing the path */ UT_InitData(); - strncpy(Original, "/cf/appslibrary.gz", OS_MAX_PATH_LEN); - Original[OS_MAX_PATH_LEN - 1] = '\0'; + strncpy(Original, "/cf/appslibrary.gz", sizeof(Original) - 1); + Original[sizeof(Original) - 1] = '\0'; UT_Report(__FILE__, __LINE__, CFE_FS_ExtractFilenameFromPath("name", FileName) == CFE_FS_INVALID_PATH, diff --git a/fsw/cfe-core/unit-test/sb_UT.c b/fsw/cfe-core/unit-test/sb_UT.c index e7522dd6d..b785daecd 100644 --- a/fsw/cfe-core/unit-test/sb_UT.c +++ b/fsw/cfe-core/unit-test/sb_UT.c @@ -217,7 +217,8 @@ void Test_SB_AppInit_EVSSendEvtFail(void) * path with different app/task names is followed on at least one event. */ memset(&TestTaskInfo, 0, sizeof(TestTaskInfo)); - strncpy((char*)TestTaskInfo.TaskName, "test", sizeof(TestTaskInfo.TaskName)-1); + strncpy(TestTaskInfo.TaskName, "test", sizeof(TestTaskInfo.TaskName)-1); + TestTaskInfo.TaskName[sizeof(TestTaskInfo.TaskName)-1] = '\0'; UT_SetDataBuffer(UT_KEY(CFE_ES_GetTaskInfo), &TestTaskInfo, sizeof(TestTaskInfo), false); /* There are three events prior to init, pipe created (1) and subscription @@ -515,7 +516,7 @@ void Test_SB_Cmds_RoutingInfoDef(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - strncpy((char *)SendRoutingInfo.Cmd.Payload.Filename, "", sizeof(SendRoutingInfo.Cmd.Payload.Filename)); + SendRoutingInfo.Cmd.Payload.Filename[0] = '\0'; /* Make some routing info by calling CFE_SB_AppInit */ SETUP(CFE_SB_AppInit()); @@ -553,8 +554,9 @@ void Test_SB_Cmds_RoutingInfoSpec(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - strncpy((char *)SendRoutingInfo.Cmd.Payload.Filename, "RoutingTstFile", - sizeof(SendRoutingInfo.Cmd.Payload.Filename)); + strncpy(SendRoutingInfo.Cmd.Payload.Filename, "RoutingTstFile", + sizeof(SendRoutingInfo.Cmd.Payload.Filename) - 1); + SendRoutingInfo.Cmd.Payload.Filename[sizeof(SendRoutingInfo.Cmd.Payload.Filename) - 1] = '\0'; CFE_SB_ProcessCmdPipePkt(&SendRoutingInfo.SBBuf); @@ -581,8 +583,9 @@ void Test_SB_Cmds_RoutingInfoCreateFail(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - strncpy((char *)SendRoutingInfo.Cmd.Payload.Filename, "RoutingTstFile", - sizeof(SendRoutingInfo.Cmd.Payload.Filename)); + strncpy(SendRoutingInfo.Cmd.Payload.Filename, "RoutingTstFile", + sizeof(SendRoutingInfo.Cmd.Payload.Filename) - 1); + SendRoutingInfo.Cmd.Payload.Filename[sizeof(SendRoutingInfo.Cmd.Payload.Filename) - 1] = '\0'; /* Make function CFE_SB_SendRtgInfo return CFE_SB_FILE_IO_ERR */ UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR); @@ -660,7 +663,7 @@ void Test_SB_Cmds_PipeInfoDef(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - strncpy((char *)SendPipeInfo.Cmd.Payload.Filename, "", sizeof(SendPipeInfo.Cmd.Payload.Filename)); + SendPipeInfo.Cmd.Payload.Filename[0] = '\0'; /* Create some pipe info */ SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); @@ -697,8 +700,10 @@ void Test_SB_Cmds_PipeInfoSpec(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - strncpy((char *)SendPipeInfo.Cmd.Payload.Filename, "PipeTstFile", - sizeof(SendPipeInfo.Cmd.Payload.Filename)); + strncpy(SendPipeInfo.Cmd.Payload.Filename, "PipeTstFile", + sizeof(SendPipeInfo.Cmd.Payload.Filename) - 1); + SendPipeInfo.Cmd.Payload.Filename[sizeof(SendPipeInfo.Cmd.Payload.Filename) - 1] = '\0'; + CFE_SB_ProcessCmdPipePkt(&SendPipeInfo.SBBuf); EVTCNT(1); @@ -792,7 +797,7 @@ void Test_SB_Cmds_MapInfoDef(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - strncpy((char *)SendMapInfo.Cmd.Payload.Filename, "", sizeof(SendMapInfo.Cmd.Payload.Filename)); + SendMapInfo.Cmd.Payload.Filename[0] = '\0'; /* Create some map info */ SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); @@ -839,8 +844,9 @@ void Test_SB_Cmds_MapInfoSpec(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - strncpy((char *)SendMapInfo.Cmd.Payload.Filename, "MapTstFile", - sizeof(SendMapInfo.Cmd.Payload.Filename)); + strncpy(SendMapInfo.Cmd.Payload.Filename, "MapTstFile", + sizeof(SendMapInfo.Cmd.Payload.Filename) - 1); + SendMapInfo.Cmd.Payload.Filename[sizeof(SendMapInfo.Cmd.Payload.Filename) - 1] = '\0'; CFE_SB_ProcessCmdPipePkt(&SendMapInfo.SBBuf);