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


##########
net/usrsock/usrsock_sendmsg.c:
##########
@@ -160,12 +161,16 @@ static int do_sendto_request(FAR struct usrsock_conn_s 
*conn,
 
   for (i = 0; i < msg->msg_iovlen; i++)
     {
-      req.buflen += msg->msg_iov[i].iov_len;
-    }
+      /* The sum of the iov_len values must fit in an ssize_t and uint32_t */
 
-  if (req.buflen > UINT32_MAX)
-    {
-      req.buflen = UINT32_MAX;
+      if (msg->msg_iov[i].iov_len > SSIZE_MAX - req.buflen ||
+          msg->msg_iov[i].iov_len > UINT32_MAX - req.buflen)

Review Comment:
   why check both UINT32_MAX and SSIZE_MAX



-- 
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