Skip to content
Snippets Groups Projects
Commit e0974c95 authored by Brad King's avatar Brad King
Browse files

ERR: Using strncpy instead of snprintf for portability.

parent a4c7c992
No related branches found
No related tags found
No related merge requests found
...@@ -526,8 +526,7 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes, char** data, int* leng ...@@ -526,8 +526,7 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, int pipes, char** data, int* leng
{ {
/* Select returned an error. Leave the error description in the /* Select returned an error. Leave the error description in the
pipe buffer. */ pipe buffer. */
snprintf(cp->ErrorMessage, KWSYSPE_PIPE_BUFFER_SIZE, strncpy(cp->ErrorMessage, strerror(errno), KWSYSPE_PIPE_BUFFER_SIZE);
"%s", strerror(errno));
/* Kill the child now. */ /* Kill the child now. */
kwsysProcess_Kill(cp); kwsysProcess_Kill(cp);
...@@ -730,7 +729,7 @@ static void kwsysProcessCleanup(kwsysProcess* cp, int error) ...@@ -730,7 +729,7 @@ static void kwsysProcessCleanup(kwsysProcess* cp, int error)
/* If cleaning up due to an error, report the error message. */ /* If cleaning up due to an error, report the error message. */
if(error) if(error)
{ {
snprintf(cp->ErrorMessage, KWSYSPE_PIPE_BUFFER_SIZE, "%s", strerror(errno)); strncpy(cp->ErrorMessage, strerror(errno), KWSYSPE_PIPE_BUFFER_SIZE);
cp->State = kwsysProcess_State_Error; cp->State = kwsysProcess_State_Error;
} }
...@@ -887,7 +886,7 @@ static void kwsysProcessChildErrorExit(kwsysProcess* cp) ...@@ -887,7 +886,7 @@ static void kwsysProcessChildErrorExit(kwsysProcess* cp)
{ {
/* Construct the error message. */ /* Construct the error message. */
char buffer[KWSYSPE_PIPE_BUFFER_SIZE]; char buffer[KWSYSPE_PIPE_BUFFER_SIZE];
snprintf(buffer, KWSYSPE_PIPE_BUFFER_SIZE, "%s", strerror(errno)); strncpy(buffer, strerror(errno), KWSYSPE_PIPE_BUFFER_SIZE);
/* Report the error to the parent through the special pipe. */ /* Report the error to the parent through the special pipe. */
write(cp->PipeWriteEnds[KWSYSPE_PIPE_ERROR], buffer, strlen(buffer)); write(cp->PipeWriteEnds[KWSYSPE_PIPE_ERROR], buffer, strlen(buffer));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment