Cygwin: AF_UNIX: sendmsg: handle messages that are too long

Return with errno EMSGSIZE if AF_UNIX_PKT_DATA_APPEND fails before any
data has been added to the packet to be sent.
This commit is contained in:
Ken Brown 2020-10-06 09:06:10 -04:00
parent 3eab592c22
commit de54d280eb
1 changed files with 9 additions and 1 deletions

View File

@ -2053,7 +2053,15 @@ fhandler_socket_unix::sendmsg (const struct msghdr *msg, int flags)
for (int i = 0; i < msg->msg_iovlen; ++i)
if (!AF_UNIX_PKT_DATA_APPEND (packet, msg->msg_iov[i].iov_base,
msg->msg_iov[i].iov_len))
break;
{
if (packet->data_len == 0)
{
set_errno (EMSGSIZE);
__leave;
}
else
break;
}
io_lock ();
/* Handle MSG_DONTWAIT in blocking mode */
if (!is_nonblocking () && (flags & MSG_DONTWAIT))