提交 b3085fd2 编写于 作者: O openharmony_ci 提交者: Gitee

!82 syscall review bugfix

Merge pull request !82 from 野生毛霉君/master
...@@ -141,6 +141,11 @@ ssize_t file_read(struct file *filep, void *buf, size_t nbytes) ...@@ -141,6 +141,11 @@ ssize_t file_read(struct file *filep, void *buf, size_t nbytes)
ssize_t read(int fd, void *buf, size_t nbytes) ssize_t read(int fd, void *buf, size_t nbytes)
{ {
if (buf == NULL || nbytes < 0)
{
set_errno(EINVAL);
return VFS_ERROR;
}
/* Did we get a valid file descriptor? */ /* Did we get a valid file descriptor? */
#if CONFIG_NFILE_DESCRIPTORS > 0 #if CONFIG_NFILE_DESCRIPTORS > 0
......
...@@ -44,7 +44,7 @@ ssize_t do_readlink(int dirfd, const char *path, char *buf, size_t bufsize) ...@@ -44,7 +44,7 @@ ssize_t do_readlink(int dirfd, const char *path, char *buf, size_t bufsize)
goto errout; goto errout;
} }
if (*path == '\0') if (*path == '\0' || buf == NULL || bufsize < 0)
{ {
ret = -EINVAL; ret = -EINVAL;
goto errout; goto errout;
......
...@@ -120,7 +120,7 @@ int do_select(int nfds, fd_set *readfds, fd_set *writefds, ...@@ -120,7 +120,7 @@ int do_select(int nfds, fd_set *readfds, fd_set *writefds,
int ndx; int ndx;
int ret; int ret;
if (nfds < 0) if (nfds < 0 || nfds >= FD_SETSIZE)
{ {
set_errno(EINVAL); set_errno(EINVAL);
return VFS_ERROR; return VFS_ERROR;
......
...@@ -39,6 +39,10 @@ int follow_symlink(int dirfd, const char *path, struct Vnode **vnode, char **ful ...@@ -39,6 +39,10 @@ int follow_symlink(int dirfd, const char *path, struct Vnode **vnode, char **ful
struct Vnode *newvnode = NULL; struct Vnode *newvnode = NULL;
char pathname[PATH_MAX] = {0}; char pathname[PATH_MAX] = {0};
if (path == NULL) {
return -EINVAL;
}
(void)strcpy_s(pathname, PATH_MAX, path); (void)strcpy_s(pathname, PATH_MAX, path);
for (int i = 0; i < CONFIG_FS_MAX_LNK_CNT; i++) for (int i = 0; i < CONFIG_FS_MAX_LNK_CNT; i++)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册