From 0e610caec857808124c13f65b142f45ff4d79b0b Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 31 Jul 2020 02:51:58 +0800 Subject: [PATCH] fs/procfs: Handle /proc/xxx/group/ correctly Signed-off-by: Xiang Xiao Change-Id: Ic9f4c38a3baf199712c5497c094dc7af84deee2c --- fs/procfs/fs_procfsproc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c index 26a549b7d3..0584a9eaa8 100644 --- a/fs/procfs/fs_procfsproc.c +++ b/fs/procfs/fs_procfsproc.c @@ -406,7 +406,12 @@ static FAR const struct proc_node_s *proc_findnode(FAR const char *relpath) for (i = 0; i < PROC_NNODES; i++) { - if (strcmp(g_nodeinfo[i]->relpath, relpath) == 0) + size_t len = strlen(g_nodeinfo[i]->relpath); + + if (strncmp(g_nodeinfo[i]->relpath, relpath, len) == 0 && + (relpath[len] == '\0' || (relpath[len] == '/' && + relpath[len + 1] == '\0' && + g_nodeinfo[i]->dtype == DTYPE_DIRECTORY))) { return g_nodeinfo[i]; }