NSH telnet: Use strncpy vs strcpy to avoid overrunning username and password buffers. From Bertold Van den Bergh
This commit is contained in:
parent
20f6470e83
commit
f1628d5055
@ -842,4 +842,6 @@
|
||||
(2014-2-20).
|
||||
* nshlib/Kconfig: Use CONFIG_DEFAULT_SMALL in selecting default
|
||||
settings (2014-2-20).
|
||||
* nshlib/nsh_telnetd.c: Use strncpy vs strcpy to avoid overrun the
|
||||
username and password buffers. From Bertold Van den Bergh (2014-2-22).
|
||||
|
||||
|
@ -131,7 +131,7 @@ int nsh_telnetlogin(struct console_stdio_s *pstate)
|
||||
fflush(pstate->cn_outstream);
|
||||
if (fgets(pstate->cn_line, CONFIG_NSH_LINELEN, INSTREAM(pstate)) != NULL)
|
||||
{
|
||||
strcpy(username, pstate->cn_line);
|
||||
strncpy(username, pstate->cn_line, sizeof(username));
|
||||
username[strlen(pstate->cn_line) - 1] = 0;
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ int nsh_telnetlogin(struct console_stdio_s *pstate)
|
||||
{
|
||||
/* Verify the username and password */
|
||||
|
||||
strcpy(password,pstate->cn_line);
|
||||
strncpy(password, pstate->cn_line, sizeof(password));
|
||||
password[strlen(pstate->cn_line) - 1] = 0;
|
||||
|
||||
if (strcmp(password, CONFIG_NSH_TELNET_PASSWORD) == 0 &&
|
||||
|
Loading…
Reference in New Issue
Block a user