From 2f1ed39bc1a9bab004bdf125e1448a022a727d03 Mon Sep 17 00:00:00 2001 From: wangchen <253227059@qq.com> Date: Thu, 10 Mar 2022 07:47:56 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=86=85=E6=BA=90=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A3=80=E8=A7=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【背景】内源代码检视问题 【修改方案】 1,按检视意见,进行资源泄露等问题的修改 【影响】 对现有的产品编译不会有影响。 re #I4WV56 Signed-off-by: wangchen --- fs/vfs/epoll/fs_epoll.c | 7 ++++++- syscall/fs_syscall.c | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/vfs/epoll/fs_epoll.c b/fs/vfs/epoll/fs_epoll.c index 1eeec53a..8591d612 100755 --- a/fs/vfs/epoll/fs_epoll.c +++ b/fs/vfs/epoll/fs_epoll.c @@ -242,6 +242,11 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev) return ret; } + if (ev == NULL) { + set_errno(EINVAL); + return -1; + } + switch (op) { case EPOLL_CTL_ADD: ret = CheckFdExist(epHead, fd); @@ -304,7 +309,7 @@ int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout return -1; } - if (maxevents <= 0) { + if ((maxevents <= 0) || (evs == NULL)) { set_errno(EINVAL); return -1; } diff --git a/syscall/fs_syscall.c b/syscall/fs_syscall.c index 99cd5213..40d4c0c2 100755 --- a/syscall/fs_syscall.c +++ b/syscall/fs_syscall.c @@ -2570,7 +2570,9 @@ int SysPselect6(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, CPY_FROM_USER(exceptfds); DUP_FROM_USER(timeout, sizeof(struct timeval)); - ((struct timeval *)timeout)->tv_usec = timeout->tv_nsec / 1000; /* 1000, convert ns to us */ + if (timeout != NULL) { + ((struct timeval *)timeout)->tv_usec = timeout->tv_nsec / 1000; /* 1000, convert ns to us */ + } if (data != NULL) { retVal = LOS_ArchCopyFromUser(&(setl.sig[0]), (int *)((UINTPTR)data[0]), sizeof(sigset_t)); -- GitLab