提交 23e5d8e5 编写于 作者: M mucor

fix: syscall review bugfix

close: #149BPF
Signed-off-by: Nmucor <mucorwang@gmail.com>
上级 952cbb9f
......@@ -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)
{
if (buf == NULL || nbytes < 0)
{
set_errno(EINVAL);
return VFS_ERROR;
}
/* Did we get a valid file descriptor? */
#if CONFIG_NFILE_DESCRIPTORS > 0
......
......@@ -44,7 +44,7 @@ ssize_t do_readlink(int dirfd, const char *path, char *buf, size_t bufsize)
goto errout;
}
if (*path == '\0')
if (*path == '\0' || buf == NULL || bufsize < 0)
{
ret = -EINVAL;
goto errout;
......
......@@ -120,7 +120,7 @@ int do_select(int nfds, fd_set *readfds, fd_set *writefds,
int ndx;
int ret;
if (nfds < 0)
if (nfds < 0 || nfds >= FD_SETSIZE)
{
set_errno(EINVAL);
return VFS_ERROR;
......
......@@ -39,6 +39,10 @@ int follow_symlink(int dirfd, const char *path, struct Vnode **vnode, char **ful
struct Vnode *newvnode = NULL;
char pathname[PATH_MAX] = {0};
if (path == NULL) {
return -EINVAL;
}
(void)strcpy_s(pathname, PATH_MAX, path);
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.
先完成此消息的编辑!
想要评论请 注册