From: Alan T. DeKok Date: Thu, 9 Jun 2022 14:22:01 +0000 (-0400) Subject: add padding to make v4 the same size as v6. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d80ed221988ebcbaf3e661a5b4dae0eda64d2a76;p=thirdparty%2Ffreeradius-server.git add padding to make v4 the same size as v6. So that when we initialize structures, omitted fields are set to zero. If we don't have a padding field, then because v4 addresses are smaller than v6 addresses, the remaining bytes after the v4 addresses are undefined. --- diff --git a/src/lib/util/inet.h b/src/lib/util/inet.h index aed9dddff49..65b1989eaa5 100644 --- a/src/lib/util/inet.h +++ b/src/lib/util/inet.h @@ -63,7 +63,10 @@ typedef struct { typedef struct { int af; //!< Address family. union { - struct in_addr v4; //!< IPv4 address. + struct { + struct in_addr v4; //!< IPv4 address. + uint8_t v4_padding[sizeof(struct in6_addr) - sizeof(struct in_addr)]; + }; struct in6_addr v6; //!< IPv6 address. } addr; uint8_t prefix; //!< Prefix length - Between 0-32 for IPv4 and 0-128 for IPv6.