From 89526241af63de42b5c782dbd7649d991d1facde Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 22 Feb 2014 11:55:30 -0600 Subject: [PATCH] For Telnetd password/username fixes from Bertikd Van den Bergh --- nshlib/nsh_telnetd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nshlib/nsh_telnetd.c b/nshlib/nsh_telnetd.c index b3e67b87c..9e712cc7b 100644 --- a/nshlib/nsh_telnetd.c +++ b/nshlib/nsh_telnetd.c @@ -132,7 +132,7 @@ int nsh_telnetlogin(struct console_stdio_s *pstate) if (fgets(pstate->cn_line, CONFIG_NSH_LINELEN, INSTREAM(pstate)) != NULL) { strncpy(username, pstate->cn_line, sizeof(username)); - username[strlen(pstate->cn_line) - 1] = 0; + username[sizeof(username) - 1] = 0; } /* Ask for the login password */ @@ -145,7 +145,7 @@ int nsh_telnetlogin(struct console_stdio_s *pstate) /* Verify the username and password */ strncpy(password, pstate->cn_line, sizeof(password)); - password[strlen(pstate->cn_line) - 1] = 0; + password[sizeof(password) - 1] = 0; if (strcmp(password, CONFIG_NSH_TELNET_PASSWORD) == 0 && strcmp(username, CONFIG_NSH_TELNET_USERNAME) == 0)