mirror of
https://github.com/libuv/libuv
synced 2025-03-28 21:13:16 +00:00
unix,win: fix wrong sizeof argument to memcpy()
Libuv was copying `sizeof(struct sockaddr_storage)` bytes from source to destination but the source was only `sizeof(struct sockaddr_in6)` bytes big, or approximately 128 vs. 16 bytes. Fixes: https://github.com/libuv/libuv/issues/2840 PR-URL: https://github.com/libuv/libuv/pull/2841 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit is contained in:
parent
78c65d0f10
commit
36549815ee
@ -925,8 +925,10 @@ static int uv__udp_set_source_membership6(uv_udp_t* handle,
|
||||
mreq.gsr_interface = 0;
|
||||
}
|
||||
|
||||
memcpy(&mreq.gsr_group, multicast_addr, sizeof(mreq.gsr_group));
|
||||
memcpy(&mreq.gsr_source, source_addr, sizeof(mreq.gsr_source));
|
||||
STATIC_ASSERT(sizeof(mreq.gsr_group) >= sizeof(*multicast_addr));
|
||||
STATIC_ASSERT(sizeof(mreq.gsr_source) >= sizeof(*source_addr));
|
||||
memcpy(&mreq.gsr_group, multicast_addr, sizeof(*multicast_addr));
|
||||
memcpy(&mreq.gsr_source, source_addr, sizeof(*source_addr));
|
||||
|
||||
if (membership == UV_JOIN_GROUP)
|
||||
optname = MCAST_JOIN_SOURCE_GROUP;
|
||||
|
@ -774,8 +774,10 @@ int uv__udp_set_source_membership6(uv_udp_t* handle,
|
||||
mreq.gsr_interface = 0;
|
||||
}
|
||||
|
||||
memcpy(&mreq.gsr_group, multicast_addr, sizeof(mreq.gsr_group));
|
||||
memcpy(&mreq.gsr_source, source_addr, sizeof(mreq.gsr_source));
|
||||
STATIC_ASSERT(sizeof(mreq.gsr_group) >= sizeof(*multicast_addr));
|
||||
STATIC_ASSERT(sizeof(mreq.gsr_source) >= sizeof(*source_addr));
|
||||
memcpy(&mreq.gsr_group, multicast_addr, sizeof(*multicast_addr));
|
||||
memcpy(&mreq.gsr_source, source_addr, sizeof(*source_addr));
|
||||
|
||||
if (membership == UV_JOIN_GROUP)
|
||||
optname = MCAST_JOIN_SOURCE_GROUP;
|
||||
|
Loading…
x
Reference in New Issue
Block a user