Skip to content

Commit

Permalink
OS-5313 recvmsg must handle 0 length iovec
Browse files Browse the repository at this point in the history
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
  • Loading branch information
jjelinek committed Apr 11, 2016
1 parent 2f63d83 commit d9ef7d7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions usr/src/uts/common/brand/lx/syscall/lx_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1808,15 +1808,19 @@ lx_recvmsg(int sock, void *msg, int flags)
}

iovcnt = smsg.msg_iovlen;
if (iovcnt <= 0 || iovcnt > IOV_MAX) {
if (iovcnt < 0 || iovcnt > IOV_MAX) {
return (set_errno(EMSGSIZE));
}
if (iovcnt > IOV_MAX_STACK) {
iovsize = iovcnt * sizeof (struct iovec);
uiov = kmem_alloc(iovsize, KM_SLEEP);
} else {
} else if (iovcnt > 0) {
iovsize = 0;
uiov = luiov;
} else {
iovsize = 0;
uiov = NULL;
goto noiov;
}

#if defined(_LP64)
Expand Down Expand Up @@ -1889,6 +1893,8 @@ lx_recvmsg(int sock, void *msg, int flags)
}
}
}

noiov:
/* Since the iovec is passed via the uio, NULL it out in the msg */
smsg.msg_iov = NULL;

Expand Down

0 comments on commit d9ef7d7

Please sign in to comment.