mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 07:08:02 +02: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;
|
struct sockaddr_in6 in6;
|
||||||
} NMSockAddrUnion;
|
} 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 \
|
#define NM_SOCK_ADDR_UNION_INIT_UNSPEC \
|
||||||
{ \
|
{ \
|
||||||
.sa = { \
|
.in6 = { \
|
||||||
.sa_family = AF_UNSPEC, \
|
.sin6_family = AF_UNSPEC, \
|
||||||
}, \
|
}, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue