linux(4): Fix control message size calculation
To determine the size in bytes needed to hold a control message and its contents of length len, CMSG_SPACE should be used. Reviewed by: Differential Revision: https://reviews.freebsd.org/D41224 MFC after: 1 week
This commit is contained in:
@@ -1852,7 +1852,7 @@ linux_recvmsg_common(struct thread *td, l_int s, struct l_msghdr *msghdr,
|
|||||||
if (error != 0)
|
if (error != 0)
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
if (outlen + LINUX_CMSG_LEN(datalen) > maxlen) {
|
if (outlen + LINUX_CMSG_SPACE(datalen) > maxlen) {
|
||||||
if (outlen == 0) {
|
if (outlen == 0) {
|
||||||
error = EMSGSIZE;
|
error = EMSGSIZE;
|
||||||
goto err;
|
goto err;
|
||||||
@@ -1871,7 +1871,7 @@ linux_recvmsg_common(struct thread *td, l_int s, struct l_msghdr *msghdr,
|
|||||||
error = copyout(data, outbuf, datalen);
|
error = copyout(data, outbuf, datalen);
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
outbuf += LINUX_CMSG_ALIGN(datalen);
|
outbuf += LINUX_CMSG_ALIGN(datalen);
|
||||||
outlen += LINUX_CMSG_LEN(datalen);
|
outlen += LINUX_CMSG_SPACE(datalen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err:
|
err:
|
||||||
|
|||||||
Reference in New Issue
Block a user