You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/12/04 11:25:05 UTC
[nuttx-apps] 03/03: nshlib:judge whether nsh login username is a valid input
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 6aef469c197a4c5d7a3a8cd766ea04fccb14ed3c
Author: huangjian <hu...@xiaomi.com>
AuthorDate: Fri Nov 4 20:37:04 2022 +0800
nshlib:judge whether nsh login username is a valid input
Signed-off-by: huangjian <hu...@xiaomi.com>
---
nshlib/nsh_login.c | 6 ++++++
nshlib/nsh_stdlogin.c | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/nshlib/nsh_login.c b/nshlib/nsh_login.c
index 3e7e370ca..9793837c4 100644
--- a/nshlib/nsh_login.c
+++ b/nshlib/nsh_login.c
@@ -178,6 +178,12 @@ int nsh_login(FAR struct console_stdio_s *pstate)
nsh_token(pstate, username, sizeof(username));
}
+ if (username[0] == '\0')
+ {
+ i--;
+ continue;
+ }
+
#ifdef CONFIG_NSH_PLATFORM_CHALLENGE
platform_challenge(challenge, sizeof(challenge));
fputs(challenge, pstate->cn_outstream);
diff --git a/nshlib/nsh_stdlogin.c b/nshlib/nsh_stdlogin.c
index d4f93f599..0ae7ae43c 100644
--- a/nshlib/nsh_stdlogin.c
+++ b/nshlib/nsh_stdlogin.c
@@ -187,6 +187,12 @@ int nsh_stdlogin(FAR struct console_stdio_s *pstate)
nsh_stdtoken(pstate, username, sizeof(username));
}
+ if (username[0] == '\0')
+ {
+ i--;
+ continue;
+ }
+
#ifdef CONFIG_NSH_PLATFORM_CHALLENGE
platform_challenge(challenge, sizeof(challenge));
printf("%s", challenge);