From cc0d53905ce9306b51bace2682ae3d1d122c7881 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Wed, 19 Aug 2020 15:16:34 +0900 Subject: [PATCH] dns: Fix memory use-after-free. * dirmngr/dns.c (dns_res_stub): Fix RESCONF usage. -- Note that this is dead code. It is for making a static analyzer happy. Signed-off-by: NIIBE Yutaka --- dirmngr/dns.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dirmngr/dns.c b/dirmngr/dns.c index 0ea6be3fb..3ac6a2d02 100644 --- a/dirmngr/dns.c +++ b/dirmngr/dns.c @@ -8301,8 +8301,14 @@ struct dns_resolver *dns_res_stub(const struct dns_options *opts, int *error) { if (!(hints = dns_hints_local(resconf, error))) goto epilog; + /* RESCONF is closed by dns_hints_local, so, get it again. */ + if (!(resconf = dns_resconf_local(error))) + goto epilog; + if (!(res = dns_res_open(resconf, hosts, hints, NULL, opts, error))) goto epilog; + else + return res; epilog: dns_resconf_close(resconf);