From c7d10a91bc337e4637afde13342df01782bb0a11 Mon Sep 17 00:00:00 2001 From: h00793410 Date: Thu, 21 Mar 2024 16:06:11 +0800 Subject: [PATCH] fix security Signed-off-by: h00793410 --- fs/hmdfs/comm/socket_adapter.c | 5 +++++ fs/hmdfs/hmdfs_server.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/hmdfs/comm/socket_adapter.c b/fs/hmdfs/comm/socket_adapter.c index e6b340b4ee72..54feb31e811d 100644 --- a/fs/hmdfs/comm/socket_adapter.c +++ b/fs/hmdfs/comm/socket_adapter.c @@ -878,6 +878,11 @@ static int hmdfs_readfile_slice(struct sendmsg_wait_queue *msg_info, loff_t offset; ssize_t written_size; + if (filp == NULL) { + hmdfs_warning("recv_info filp is NULL \n"); + return -EINVAL; + } + if (atomic_read(&recv_info->state) != FILE_RECV_PROCESS) return -EBUSY; diff --git a/fs/hmdfs/hmdfs_server.c b/fs/hmdfs/hmdfs_server.c index ae4a941a4d71..d09b4b6ced2b 100644 --- a/fs/hmdfs/hmdfs_server.c +++ b/fs/hmdfs/hmdfs_server.c @@ -37,7 +37,7 @@ static void find_first_no_slash(const char **name, int *len) const char *s = *name; int l = *len; - while (*s == '/' && l > 0) { + while (l > 0 && *s == '/') { s++; l--; } @@ -51,7 +51,7 @@ static void find_first_slash(const char **name, int *len) const char *s = *name; int l = *len; - while (*s != '/' && l > 0) { + while (l > 0 && *s != '/') { s++; l--; } -- Gitee