]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dns_server: Use talloc_realloc_zero() to avoid explicit ZERO_STRUCT()
authorVolker Lendecke <vl@samba.org>
Wed, 17 Jun 2026 06:02:35 +0000 (08:02 +0200)
committerAnoop C S <anoopcs@samba.org>
Mon, 3 Aug 2026 09:05:30 +0000 (09:05 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source4/dns_server/dns_query.c

index d0d733bb5b9aca9208f0d3263a9eb1391a69be16..872eceab2f3f9541a08ac7b4547b0a188615ee0b 100644 (file)
@@ -62,13 +62,11 @@ static WERROR add_response_rr(const char *name,
        /*
         * "ans" is always non-NULL and thus its own talloc context
         */
-       ans = talloc_realloc(ans, ans, struct dns_res_rec, ai+1);
+       ans = talloc_realloc_zero(ans, ans, struct dns_res_rec, ai+1);
        if (ans == NULL) {
                return WERR_NOT_ENOUGH_MEMORY;
        }
 
-       ZERO_STRUCT(ans[ai]);
-
        switch (rec->wType) {
        case DNS_QTYPE_CNAME:
                ans[ai].rdata.cname_record = talloc_strdup(ans, rec->data.cname);
@@ -155,13 +153,11 @@ static WERROR add_dns_res_rec(struct dns_res_rec **pdst,
                return WERR_BUFFER_OVERFLOW;
        }
 
-       dst = talloc_realloc(dst, dst, struct dns_res_rec, di+1);
+       dst = talloc_realloc_zero(dst, dst, struct dns_res_rec, di+1);
        if (dst == NULL) {
                return WERR_NOT_ENOUGH_MEMORY;
        }
 
-       ZERO_STRUCT(dst[di]);
-
        dst[di] = (struct dns_res_rec) {
                .name = talloc_strdup(dst, src->name),
                .rr_type = src->rr_type,