net_socket: check underflow condition happening on x86_64.
* move the test for the availability of the add_anillary_data function in the protocol out of the loop, as suggested by Axel. * fix #12737.
This commit is contained in:
@@ -221,18 +221,23 @@ add_ancillary_data(net_socket* socket, ancillary_data_container* container,
|
|||||||
{
|
{
|
||||||
cmsghdr* header = (cmsghdr*)data;
|
cmsghdr* header = (cmsghdr*)data;
|
||||||
|
|
||||||
while (dataLen > 0) {
|
if (dataLen == 0)
|
||||||
if (header->cmsg_len < sizeof(cmsghdr) || header->cmsg_len > dataLen)
|
return B_OK;
|
||||||
return B_BAD_VALUE;
|
|
||||||
|
|
||||||
if (socket->first_info->add_ancillary_data == NULL)
|
if (socket->first_info->add_ancillary_data == NULL)
|
||||||
return B_NOT_SUPPORTED;
|
return B_NOT_SUPPORTED;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (header->cmsg_len < CMSG_LEN(0) || header->cmsg_len > dataLen)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
status_t status = socket->first_info->add_ancillary_data(
|
status_t status = socket->first_info->add_ancillary_data(
|
||||||
socket->first_protocol, container, header);
|
socket->first_protocol, container, header);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
if (dataLen <= _ALIGN(header->cmsg_len))
|
||||||
|
break;
|
||||||
dataLen -= _ALIGN(header->cmsg_len);
|
dataLen -= _ALIGN(header->cmsg_len);
|
||||||
header = (cmsghdr*)((uint8*)header + _ALIGN(header->cmsg_len));
|
header = (cmsghdr*)((uint8*)header + _ALIGN(header->cmsg_len));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user