xiaoxiang781216 commented on code in PR #2885: URL: https://github.com/apache/nuttx-apps/pull/2885#discussion_r1878438424
########## nshlib/nsh_console.c: ########## @@ -442,6 +442,13 @@ FAR struct console_stdio_s *nsh_newconsole(bool isctty) /* Initialize the input stream */ INFD(pstate) = STDIN_FILENO; + + /* Initialize current working directory */ + +#ifdef CONFIG_DISABLE_ENVIRON + strncpy(pstate->cn_vtbl.cwd, CONFIG_LIBC_HOMEDIR, Review Comment: strlcpy ########## nshlib/nsh_envcmds.c: ########## @@ -273,6 +273,13 @@ int cmd_cd(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) nsh_error(vtbl, g_fmtcmdfailed, argv[0], "chdir", NSH_ERRNO); ret = ERROR; } +#ifdef CONFIG_DISABLE_ENVIRON + else + { + strncpy(vtbl->cwd, path, + strnlen(path, sizeof(vtbl->cwd) - 1) + 1); Review Comment: whynot simply sizeof(vtbl->cwd) ########## nshlib/nsh_envcmds.c: ########## @@ -273,6 +273,13 @@ int cmd_cd(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) nsh_error(vtbl, g_fmtcmdfailed, argv[0], "chdir", NSH_ERRNO); ret = ERROR; } +#ifdef CONFIG_DISABLE_ENVIRON + else + { + strncpy(vtbl->cwd, path, Review Comment: ```suggestion strlcpy(vtbl->cwd, path, ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org