mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 17:56:17 +01:00
gsocket: Add assertions about socket address sizes for memcpy()
These `memcpy()` calls only happen if `g_inet_address_get_family(group) == G_SOCKET_FAMILY_IPV4`, so the assertions should never fail. It’s helpful for understanding the code, and for static analysis, to add the assertions though. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Coverity CID: #1486858
This commit is contained in:
parent
606bdcdb18
commit
ff944776fe
@ -2604,8 +2604,12 @@ g_socket_multicast_group_operation_ssm (GSocket *socket,
|
|||||||
S_ADDR_FIELD(mc_req_src) = iface_addr->sin_addr.s_addr;
|
S_ADDR_FIELD(mc_req_src) = iface_addr->sin_addr.s_addr;
|
||||||
#endif /* defined(G_OS_WIN32) && defined (HAVE_IF_NAMETOINDEX) */
|
#endif /* defined(G_OS_WIN32) && defined (HAVE_IF_NAMETOINDEX) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_assert (g_inet_address_get_native_size (group) == sizeof (mc_req_src.imr_multiaddr));
|
||||||
memcpy (&mc_req_src.imr_multiaddr, g_inet_address_to_bytes (group),
|
memcpy (&mc_req_src.imr_multiaddr, g_inet_address_to_bytes (group),
|
||||||
g_inet_address_get_native_size (group));
|
g_inet_address_get_native_size (group));
|
||||||
|
|
||||||
|
g_assert (g_inet_address_get_native_size (source_specific) == sizeof (mc_req_src.imr_sourceaddr));
|
||||||
memcpy (&mc_req_src.imr_sourceaddr,
|
memcpy (&mc_req_src.imr_sourceaddr,
|
||||||
g_inet_address_to_bytes (source_specific),
|
g_inet_address_to_bytes (source_specific),
|
||||||
g_inet_address_get_native_size (source_specific));
|
g_inet_address_get_native_size (source_specific));
|
||||||
|
Loading…
Reference in New Issue
Block a user