Skip to content

Commit 4a1e6bc

Browse files
zachreiznervivier
authored andcommitted
linux-user: allow NULL msg in recvfrom
The kernel allows a NULL msg in recvfrom so that he size of the next message may be queried before allocating a correctly sized buffer. This change allows the syscall translator to pass along the NULL msg pointer instead of returning early with EFAULT. Signed-off-by: Zach Reizner <zachr@google.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <CAFNex=DvFCq=AQf+=19fTfw-T8eZZT=3NnFFm2JMFvVr5QgQyA@mail.gmail.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
1 parent 23fff7a commit 4a1e6bc

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

linux-user/syscall.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3679,9 +3679,14 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, size_t len, int flags,
36793679
void *host_msg;
36803680
abi_long ret;
36813681

3682-
host_msg = lock_user(VERIFY_WRITE, msg, len, 0);
3683-
if (!host_msg)
3684-
return -TARGET_EFAULT;
3682+
if (!msg) {
3683+
host_msg = NULL;
3684+
} else {
3685+
host_msg = lock_user(VERIFY_WRITE, msg, len, 0);
3686+
if (!host_msg) {
3687+
return -TARGET_EFAULT;
3688+
}
3689+
}
36853690
if (target_addr) {
36863691
if (get_user_u32(addrlen, target_addrlen)) {
36873692
ret = -TARGET_EFAULT;

0 commit comments

Comments
 (0)