nshlib:judge whether nsh login username is a valid input

Signed-off-by: huangjian <huangjian@xiaomi.com>
This commit is contained in:
huangjian 2022-11-04 20:37:04 +08:00 committed by Xiang Xiao
parent 88fff23d34
commit 6aef469c19
2 changed files with 12 additions and 0 deletions

View File

@ -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);

View File

@ -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);