yamt commented on code in PR #15603:
URL: https://github.com/apache/nuttx/pull/15603#discussion_r1924584562


##########
fs/vfs/fs_uio.c:
##########
@@ -131,7 +131,7 @@ int uio_init(FAR struct uio *uio, FAR const struct iovec 
*iov, int iovcnt)
   resid = uio_calc_resid(uio);
   if (resid < 0)
     {
-      return -EINVAL;
+      return resid;

Review Comment:
   unrelated change



##########
fs/vfs/fs_read.c:
##########
@@ -361,5 +352,6 @@ ssize_t read(int fd, FAR void *buf, size_t nbytes)
 
   iov.iov_base = buf;
   iov.iov_len = nbytes;
+

Review Comment:
   unrelated change



##########
fs/vfs/fs_uio.c:
##########
@@ -82,8 +82,8 @@ ssize_t uio_calc_resid(FAR const struct uio *uio)
 void uio_advance(FAR struct uio *uio, size_t sz)
 {
   FAR const struct iovec *iov = uio->uio_iov;
-  int iovcnt = uio->uio_iovcnt;
   size_t offset_in_iov = uio->uio_offset_in_iov;
+  int iovcnt = uio->uio_iovcnt;

Review Comment:
   unrelated change.
   
   do you order variables by size?
   



##########
fs/vfs/fs_read.c:
##########
@@ -74,36 +69,36 @@ static ssize_t file_readv_compat(FAR struct file *filep, 
FAR struct uio *uio)
           continue;
         }
 
-      buffer    = iov[i].iov_base;
-      remaining = iov[i].iov_len;
+      /* Sanity check to avoid total length overflow */
+
+      if (ntotal > 0 && SSIZE_MAX - ntotal < iov[i].iov_len)
+        {
+          break;

Review Comment:
   can you make the behavior consistent with uio case? (ie. return -EINVAL)
   
   ditto for write



##########
fs/vfs/fs_read.c:
##########
@@ -297,6 +287,7 @@ ssize_t nx_read(int fd, FAR void *buf, size_t nbytes)
 
   iov.iov_base = buf;
   iov.iov_len = nbytes;
+

Review Comment:
   unrelated change



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to