From: Douglas Bagnall Date: Tue, 13 Apr 2021 04:31:10 +0000 (+1200) Subject: dns scavenging: avoid leak in dns_tombstone_records X-Git-Tag: tevent-0.11.0~289 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=f52ce9f954afe155ee30ddfeedfcff777aae8492;p=thirdparty%2Fsamba.git dns scavenging: avoid leak in dns_tombstone_records As always, we forget to free our zones. Also to check our zones. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/source4/dsdb/kcc/scavenge_dns_records.c b/source4/dsdb/kcc/scavenge_dns_records.c index 1d8cb2213c6..6865cedd187 100644 --- a/source4/dsdb/kcc/scavenge_dns_records.c +++ b/source4/dsdb/kcc/scavenge_dns_records.c @@ -336,23 +336,32 @@ NTSTATUS dns_tombstone_records(TALLOC_CTX *mem_ctx, unix_to_nt_time(&entombed_time, unix_now); dns_timestamp = unix_to_dns_timestamp(unix_now); + tmp_ctx = talloc_new(mem_ctx); + if (tmp_ctx == NULL) { + return NT_STATUS_NO_MEMORY; + } + + ret = dns_common_zones(samdb, tmp_ctx, NULL, &zones); + if (!NT_STATUS_IS_OK(ret)) { + TALLOC_FREE(tmp_ctx); + return ret; + } - dns_common_zones(samdb, mem_ctx, NULL, &zones); for (z = zones; z; z = z->next) { - tmp_ctx = talloc_new(NULL); ret = dns_tombstone_records_zone(tmp_ctx, samdb, z, dns_timestamp, entombed_time, error_string); - TALLOC_FREE(tmp_ctx); if (NT_STATUS_EQUAL(ret, NT_STATUS_PROPSET_NOT_FOUND)) { continue; } else if (!NT_STATUS_IS_OK(ret)) { + TALLOC_FREE(tmp_ctx); return ret; } } + TALLOC_FREE(tmp_ctx); return NT_STATUS_OK; }