mirror of
https://github.com/apache/nuttx.git
synced 2026-02-06 21:03:15 +08:00
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:
@@ -164,6 +164,18 @@ ssize_t file_readv(FAR struct file *filep,
|
||||
DEBUGASSERT(filep);
|
||||
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? */
|
||||
|
||||
for (ret = 0; ret < iovcnt; ret++)
|
||||
|
||||
@@ -153,6 +153,18 @@ ssize_t file_writev(FAR struct file *filep,
|
||||
return -EACCES;
|
||||
}
|
||||
|
||||
/* Check buffer count and pointer for iovec */
|
||||
|
||||
if (iovcnt == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (iov == NULL)
|
||||
{
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
/* Are all iov_base accessible? */
|
||||
|
||||
for (ret = 0; ret < iovcnt; ret++)
|
||||
|
||||
Reference in New Issue
Block a user