Skip to content

Commit fd9db4a

Browse files
author
elizabeth.e.ash@nasa.gov
committed
Fix #231, to_lab app: Changing null terminator manipulation in string to follow best practices of using strncpy.
1 parent fcc3ef8 commit fd9db4a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

fsw/src/to_lab_app.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,14 @@ CFE_Status_t TO_LAB_init(void)
124124
TO_LAB_Global.AllowPassthru = true;
125125
TO_LAB_Global.downlink_on = false;
126126
PipeDepth = TO_LAB_PLATFORM_CMD_PIPE_DEPTH;
127-
strncpy(PipeName, "TO_LAB_CMD_PIPE", sizeof(PipeName) - 1);
127+
128+
/* sizeof()-1 makes sure there's room for the null terminator when using strncpy */
129+
strncpy(PipeName, "TO_LAB_CMD_PIPE", sizeof(PipeName) -1);
130+
/* Make sure a null terminator is added to the strncpy destination */
131+
PipeName[sizeof(PipeName) - 1] = '\0';
128132
ToTlmPipeDepth = TO_LAB_PLATFORM_TLM_PIPE_DEPTH;
129133
strncpy(ToTlmPipeName, "TO_LAB_TLM_PIPE", sizeof(ToTlmPipeName) - 1);
134+
ToTlmPipeName[sizeof(ToTlmPipeName) - 1] = '\0';
130135

131136
/*
132137
** Register with EVS

0 commit comments

Comments
 (0)