fs/vfs: check buffer count and pointer for iovec
There are iovecs provided by user such as readv(). Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
parent
89df084b0e
commit
5e94d4482b
2 changed files with 24 additions and 0 deletions
|
|
@ -164,6 +164,18 @@ ssize_t file_readv(FAR struct file *filep,
|
||||||
DEBUGASSERT(filep);
|
DEBUGASSERT(filep);
|
||||||
inode = filep->f_inode;
|
inode = filep->f_inode;
|
||||||
|
|
||||||
|
/* Check buffer count and pointer for iovec */
|
||||||
|
|
||||||
|
if (iovcnt == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iov == NULL)
|
||||||
|
{
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
/* Are all iov_base accessible? */
|
/* Are all iov_base accessible? */
|
||||||
|
|
||||||
for (ret = 0; ret < iovcnt; ret++)
|
for (ret = 0; ret < iovcnt; ret++)
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,18 @@ ssize_t file_writev(FAR struct file *filep,
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check buffer count and pointer for iovec */
|
||||||
|
|
||||||
|
if (iovcnt == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iov == NULL)
|
||||||
|
{
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
/* Are all iov_base accessible? */
|
/* Are all iov_base accessible? */
|
||||||
|
|
||||||
for (ret = 0; ret < iovcnt; ret++)
|
for (ret = 0; ret < iovcnt; ret++)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue