]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:libcli:resolve:dns_ex fix cast-align warning
authorGary Lockyer <gary@catalyst.net.nz>
Wed, 8 Apr 2026 21:34:04 +0000 (09:34 +1200)
committerGary Lockyer <gary@samba.org>
Fri, 29 May 2026 03:13:32 +0000 (03:13 +0000)
rr->data is allocated via talloc in dns_unmarshal_rr so it will be correctly
aligned

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
source4/libcli/resolve/dns_ex.c

index 09cc10064dc34f5c32a522bc2b2b47e607b53bac..822fc456847386ef73ec0d53e18c8e3d5e041ca1 100644 (file)
@@ -123,18 +123,30 @@ static int reply_to_addrs(TALLOC_CTX *mem_ctx, uint32_t *a_num,
                /* we are only interested in A and AAAA records */
                switch (rr->type) {
                case QTYPE_A:
+                       /*
+                        * rr->data will be correctly aligned as it's allocated
+                        * in dns_unmarshall_rr
+                        */
                        addr = inet_ntop(AF_INET,
-                                        (struct in_addr *)rr->data,
-                                        addrstr, sizeof(addrstr));
+                                        discard_align_p(struct in_addr,
+                                                        rr->data),
+                                        addrstr,
+                                        sizeof(addrstr));
                        if (addr == NULL) {
                                continue;
                        }
                        break;
                case QTYPE_AAAA:
 #ifdef HAVE_IPV6
+                       /*
+                        * rr->data will be correctly aligned as it's allocated
+                        * in dns_unmarshal_rr
+                        */
                        addr = inet_ntop(AF_INET6,
-                                        (struct in6_addr *)rr->data,
-                                        addrstr, sizeof(addrstr));
+                                        discard_align_p(struct in6_addr,
+                                                        rr->data),
+                                        addrstr,
+                                        sizeof(addrstr));
 #else
                        addr = NULL;
 #endif