Rewrote NULL-termination code to avoid writing to a const array
This commit is contained in:
parent
35f8d24c2e
commit
4ea2312f23
1 changed files with 3 additions and 3 deletions
|
@ -30,7 +30,7 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: shell-udpsend.c,v 1.3 2010/02/04 11:20:09 adamdunkels Exp $
|
||||
* $Id: shell-udpsend.c,v 1.4 2010/02/04 14:59:08 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
@ -84,9 +84,9 @@ PROCESS_THREAD(shell_udpsend_process, ev, data)
|
|||
"udpsend <server> <port> [localport]: server as address", "");
|
||||
PROCESS_EXIT();
|
||||
}
|
||||
/* NULL-terminate the server string before copying. */
|
||||
*next = 0;
|
||||
strncpy(server, data, sizeof(server));
|
||||
/* NULL-terminate the server string. */
|
||||
server[next - (char *)data] = 0;
|
||||
++next;
|
||||
port = shell_strtolong(next, &nextptr);
|
||||
|
||||
|
|
Loading…
Reference in a new issue