From 697e3bed0aba70f19760734101c328e39fc85876 Mon Sep 17 00:00:00 2001 From: zhengyu9 Date: Thu, 20 Jun 2024 17:55:23 +0800 Subject: [PATCH] apps/nshlib/cmd_cd: Modify the logic of cd Modify the implementation logic of changing directory. There's an error handling the path incluing "../" or "./" bug examples: nsh> cd proc/self/group nsh> cd ../.. nsh: cd: chdir failed: 2 nsh> pwd /proc/self nsh> ls /proc/self: status cmdline stack group/ nsh> cd ./group nsh: cd: chdir failed: 2 Signed-off-by: zhengyu9 --- nshlib/nsh_fsutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nshlib/nsh_fsutils.c b/nshlib/nsh_fsutils.c index 30c2a19e9f..50f67d6d68 100644 --- a/nshlib/nsh_fsutils.c +++ b/nshlib/nsh_fsutils.c @@ -583,7 +583,7 @@ FAR char *nsh_getdirpath(FAR struct nsh_vtbl_s *vtbl, snprintf(vtbl->iobuffer, IOBUFFERSIZE, "%s/%s", dirpath, path); } - return strdup(vtbl->iobuffer); + return lib_realpath(vtbl->iobuffer, NULL, true); } #endif