Fixed wrong check on size of sockaddr_in passed in the message, causing the function to return EINVAL on BSD/MacOS for non-connected sockets

This commit is contained in:
Fabrizio Bertocci 2021-04-07 15:53:58 -04:00
parent 7a25049ba9
commit dccbb44d25

View file

@ -43,7 +43,7 @@ ssize_t sendmsg(int fd, const struct msghdr *msg, int flags) {
/* An optional address is provided, convert it to the BSD form */
char addr2[128];
struct msghdr msg2;
if (sizeof(addr2) > msg->msg_namelen) return einval();
if (msg->msg_namelen > sizeof(addr2)) return einval();
memcpy(&addr2[0], msg->msg_name, msg->msg_namelen);
sockaddr2bsd(&addr2[0]);