Swatantra-66 commented on code in PR #21492:
URL: https://github.com/apache/nuttx/pull/21492#discussion_r4497789789


##########
net/local/local_sendmsg.c:
##########
@@ -430,26 +431,44 @@ ssize_t local_sendmsg(FAR struct socket *psock, FAR const 
struct msghdr *msg,
   if (msg->msg_control &&
       msg->msg_controllen > sizeof(struct cmsghdr))
     {
+      /* Stream sockets require data to be sent with control messages */
+
+      if (psock->s_type == SOCK_STREAM)
+        {
+          size_t total = 0;
+          size_t i;
+
+          for (i = 0; i < iovlen; i++)
+            {
+              total += buf[i].iov_len;
+            }
+
+          if (total == 0)
+            {
+              return -EINVAL;
+            }
+        }
+
       count = local_sendctl(conn, msg);
       if (count < 0)
         {
           return count;
         }
     }
 
-  len = to ? local_sendto(psock, buf, len, flags, to, tolen) :
-             local_send(psock, buf, len, flags);
+  ret = to ? local_sendto(psock, buf, iovlen, flags, to, tolen) :
+             local_send(psock, buf, iovlen, flags);
 
-  if (len < 0 && count > 0)
+  if (ret < 0 && count > 0)

Review Comment:
   Thank you for investigating and fixing the follow-up edge case in #21508



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