Skip to content

Commit

Permalink
Merge pull request #157 from jphickey/fix-156-stringops
Browse files Browse the repository at this point in the history
Fix #156, termination on strncpy
  • Loading branch information
astrogeco authored May 8, 2020
2 parents 09b62df + b2dd44d commit d1872ed
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions fsw/pc-linux/src/cfe_psp_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ void OS_Application_Startup(void)
switch( opt )
{
case 'R':
strncpy(CommandData.ResetType, optarg, CFE_PSP_RESET_NAME_LENGTH);
strncpy(CommandData.ResetType, optarg, CFE_PSP_RESET_NAME_LENGTH-1);
CommandData.ResetType[CFE_PSP_RESET_NAME_LENGTH-1] = 0;

if ((strncmp(CommandData.ResetType, "PO", CFE_PSP_RESET_NAME_LENGTH ) != 0 ) &&
(strncmp(CommandData.ResetType, "PR", CFE_PSP_RESET_NAME_LENGTH ) != 0 ))
{
Expand Down Expand Up @@ -214,7 +216,8 @@ void OS_Application_Startup(void)
break;

case 'N':
strncpy(CommandData.CpuName, optarg, CFE_PSP_CPU_NAME_LENGTH );
strncpy(CommandData.CpuName, optarg, CFE_PSP_CPU_NAME_LENGTH-1 );
CommandData.CpuName[CFE_PSP_CPU_NAME_LENGTH-1] = 0;
printf("CFE_PSP: CPU Name: %s\n",CommandData.CpuName);
CommandData.GotCpuName = 1;
break;
Expand Down Expand Up @@ -521,7 +524,8 @@ void CFE_PSP_ProcessArgumentDefaults(CFE_PSP_CommandData_t *CommandDataDefault)

if ( CommandDataDefault->GotCpuName == 0 )
{
strncpy(CommandDataDefault->CpuName, CFE_PSP_CPU_NAME, CFE_PSP_CPU_NAME_LENGTH );
strncpy(CommandDataDefault->CpuName, CFE_PSP_CPU_NAME, CFE_PSP_CPU_NAME_LENGTH-1 );
CommandDataDefault->CpuName[CFE_PSP_CPU_NAME_LENGTH-1] = 0;
printf("CFE_PSP: Default CPU Name: %s\n",CFE_PSP_CPU_NAME);
CommandDataDefault->GotCpuName = 1;
}
Expand Down

0 comments on commit d1872ed

Please sign in to comment.