mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 15:08:21 +00:00
recvmsg: fix return of ctrl length and flags
This commit is contained in:
@@ -70,9 +70,6 @@ syscallret_t syscall_recvmsg(context_t *, int fd, msghdr_t *umsghdr, int flags)
|
|||||||
if (ret.errno)
|
if (ret.errno)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
msghdr.ctrllen = desc.ctrldone;
|
|
||||||
msghdr.flags = (desc.flags & SOCKET_RECV_FLAGS_CTRLTRUNCATED) ? MSG_CTRUNC : 0;
|
|
||||||
|
|
||||||
uintmax_t iovoffset = 0;
|
uintmax_t iovoffset = 0;
|
||||||
for (int i = 0; i < msghdr.iovcount; ++i) {
|
for (int i = 0; i < msghdr.iovcount; ++i) {
|
||||||
ret.errno = usercopy_touser(msghdr.iov[i].addr, (void *)((uintptr_t)buffer + iovoffset), msghdr.iov[i].len);
|
ret.errno = usercopy_touser(msghdr.iov[i].addr, (void *)((uintptr_t)buffer + iovoffset), msghdr.iov[i].len);
|
||||||
@@ -103,11 +100,20 @@ syscallret_t syscall_recvmsg(context_t *, int fd, msghdr_t *umsghdr, int flags)
|
|||||||
if (ret.errno)
|
if (ret.errno)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
ret.errno = usercopy_touser(&umsghdr->ctrllen, &desc.ctrldone, sizeof(desc.ctrldone));
|
||||||
|
if (ret.errno)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
ret.errno = usercopy_touser(ptr, msghdr.msgctrl, desc.ctrldone);
|
ret.errno = usercopy_touser(ptr, msghdr.msgctrl, desc.ctrldone);
|
||||||
if (ret.errno)
|
if (ret.errno)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret.errno == 0) {
|
||||||
|
int return_flags = (desc.flags & SOCKET_RECV_FLAGS_CTRLTRUNCATED) ? MSG_CTRUNC : 0;
|
||||||
|
ret.errno = usercopy_touser(&umsghdr->flags, &return_flags, sizeof(return_flags));
|
||||||
|
}
|
||||||
|
|
||||||
ret.ret = ret.errno ? -1 : desc.donecount;
|
ret.ret = ret.errno ? -1 : desc.donecount;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|||||||
Reference in New Issue
Block a user