mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-24 20:40:06 +01:00
platform: ensure NM_SOCK_ADDR_UNION_INIT_UNSPEC() fully initializes union
In C, initialization of a union does not define that excess memory is initialized. Ensure that, by initializing the largest member of the NMSockAddrUnion union.
This commit is contained in:
parent
b3909c36f6
commit
7bf2ddf73f
1 changed files with 6 additions and 2 deletions
|
|
@ -34,10 +34,14 @@ typedef union {
|
|||
struct sockaddr_in6 in6;
|
||||
} NMSockAddrUnion;
|
||||
|
||||
G_STATIC_ASSERT(sizeof(NMSockAddrUnion) == sizeof(((NMSockAddrUnion *) NULL)->in6));
|
||||
|
||||
/* we initialize the largest union member, to ensure that all fields are initialized. */
|
||||
|
||||
#define NM_SOCK_ADDR_UNION_INIT_UNSPEC \
|
||||
{ \
|
||||
.sa = { \
|
||||
.sa_family = AF_UNSPEC, \
|
||||
.in6 = { \
|
||||
.sin6_family = AF_UNSPEC, \
|
||||
}, \
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue