xiaoxiang781216 commented on code in PR #21544:
URL: https://github.com/apache/nuttx/pull/21544#discussion_r4504591177


##########
fs/vfs/fs_write.c:
##########


Review Comment:
   merge into line 137



##########
fs/vfs/fs_read.c:
##########
@@ -183,38 +173,44 @@ ssize_t file_readv(FAR struct file *filep,
    * kernel builds will fail to load elf binaries found at 0.
    */
 
-#if !defined(CONFIG_BUILD_KERNEL) || CONFIG_ARCH_TEXT_VBASE != 0
+  for (i = 0; i < iovcnt; i++)
+    {
+      if (SSIZE_MAX - len < iov[i].iov_len)
+        {
+          return -EINVAL;
+        }
 
-  /* Are all iov_base accessible? */
+      len += iov[i].iov_len;
 
-  for (ret = 0; ret < iovcnt; ret++)
-    {
-      if (iov[ret].iov_base == NULL)
+#if !defined(CONFIG_BUILD_KERNEL) || CONFIG_ARCH_TEXT_VBASE != 0
+      /* Are all iov_base accessible? */
+
+      if (iov[i].iov_base == NULL && iov[i].iov_len != 0)
         {
           return -EFAULT;
         }
-    }
 #endif
-
-  ret = -EBADF;
+    }
 
   /* Was this file opened for read access? */
 
   if ((filep->f_oflags & O_ACCMODE) == O_WRONLY)
     {
       /* No.. File is not read-able */
 
-      ret = -EBADF;
+      return -EBADF;
     }
 
+  ret = -EBADF;

Review Comment:
   merge to line 152



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to