]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add padding to make v4 the same size as v6.
authorAlan T. DeKok <aland@freeradius.org>
Thu, 9 Jun 2022 14:22:01 +0000 (10:22 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 9 Jun 2022 14:41:47 +0000 (10:41 -0400)
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.

src/lib/util/inet.h

index aed9dddff499e341994a2db7d3b8430c9cef4513..65b1989eaa5b96f68dbfbd4d9696cbe73367ba2c 100644 (file)
@@ -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.