From 93658ba4782505c5c37d765b88d2fbcc4b27e956 Mon Sep 17 00:00:00 2001 From: gao-rongxin Date: Wed, 8 Sep 2021 19:49:51 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3shell=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E4=B8=ADrm=20-r=E6=8C=87=E4=BB=A4=E5=B0=9D=E8=AF=95?= =?UTF-8?q?=E5=88=A0=E9=99=A4/dev=E4=B8=8B=E8=8A=82=E7=82=B9=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=87=BA=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 主干不存在该问题,已解决. shell命令rm中当opendir时没有正确判断opendir的返回值, 导致后续访问空指针. 检查opendir的返回值,当opendir失败时返回-1. Close #I48FLX Signed-off-by: gao-rongxin --- fs/vfs/vfs_cmd/vfs_shellcmd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/vfs/vfs_cmd/vfs_shellcmd.c b/fs/vfs/vfs_cmd/vfs_shellcmd.c index d8a4caf8..7f2050ee 100755 --- a/fs/vfs/vfs_cmd/vfs_shellcmd.c +++ b/fs/vfs/vfs_cmd/vfs_shellcmd.c @@ -838,6 +838,10 @@ static int os_shell_cmd_do_rmdir(const char *pathname) return remove(pathname); } d = opendir(pathname); + if (d == NULL) + { + return -1; + } while (1) { dirent = readdir(d); -- GitLab