From: Erik M. <er...@us...> - 2001-12-19 20:00:20
|
Update of /cvsroot/blob/blob/src/diag In directory usw-pr-cvs1:/tmp/cvs-serv30998/src/diag Modified Files: commands.c command_hist.c Log Message: Remove strcpy() in favour of strncpy(). Again, this forces you to think before you copy a string. The changes in the files are trivial again. Index: commands.c =================================================================== RCS file: /cvsroot/blob/blob/src/diag/commands.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- commands.c 2001/10/07 23:32:05 1.3 +++ commands.c 2001/12/19 20:00:15 1.4 @@ -104,7 +104,7 @@ /* display it */ SerialOutputString(cmd); i = numRead = strlen( cmd ); - strcpy( command, cmd ); + strncpy( command, cmd, MAX_COMMANDLINE_LENGTH ); } else if ( c == CMDHIST_KEY_DN ) { char *cmd = NULL; /* get cmd from history */ @@ -119,7 +119,7 @@ /* display it */ SerialOutputString(cmd); i = numRead = strlen( cmd ); - strcpy( command, cmd ); + strncpy( command, cmd, MAX_COMMANDLINE_LENGTH ); } else { command[i++] = c; numRead++; Index: command_hist.c =================================================================== RCS file: /cvsroot/blob/blob/src/diag/command_hist.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- command_hist.c 2001/10/07 23:32:05 1.1 +++ command_hist.c 2001/12/19 20:00:15 1.2 @@ -89,7 +89,7 @@ if ( strlen( cmd ) == 0 ) return 0; - strcpy( cmdhistory[ cmdhist_write ], cmd ); + strlcpy( cmdhistory[ cmdhist_write ], cmd, MAX_COMMANDLINE_LENGTH ); cmdhist_write ++; cmdhist_write = cmdhist_write % MAX_HIST; |