From b53bbb15c5b7ec5599082c4c96db6f894b7c65d6 Mon Sep 17 00:00:00 2001 From: tianxin7 Date: Thu, 2 Sep 2021 14:46:31 +0800 Subject: [PATCH] fs:add _POSIX_OPEN_MAX limit to files_extend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 田昕 --- fs/inode/fs_files.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c index ba310176f42..7d4eaf77d55 100644 --- a/fs/inode/fs_files.c +++ b/fs/inode/fs_files.c @@ -71,6 +71,11 @@ static int files_extend(FAR struct filelist *list, size_t row) return 0; } + if (row * CONFIG_NFILE_DESCRIPTORS_PER_BLOCK > _POSIX_OPEN_MAX) + { + return -EMFILE; + } + tmp = kmm_realloc(list->fl_files, sizeof(FAR struct file *) * row); DEBUGASSERT(tmp); if (tmp == NULL)