From 905a6129147e7ee80e8918e23efe212433b8cce7 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 6 Sep 2017 15:46:54 +0200 Subject: [PATCH 30] resolv: Fix memory leak with OOM during resolv.conf parsing [BZ #22095] (cherry picked from commit 5670c4ab256114e869b1df4b05653aa5f909182c) --- ChangeLog | 6 ++++++ NEWS | 1 + resolv/res_init.c | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index fa215c2729..ef2041b9e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2017-09-06 Florian Weimer + [BZ #22095] + * resolv/res_init.c (res_vinit_1): Avoid memory leak in case of + dynarray allocation failure. + +2017-09-06 Florian Weimer + Remove dead PTR IPv4-to-IPv6 mapping code from nss_dns. * resolv/nss_dns/dns-host.c (getanswer_r): Remove dead code. * resolv/tst-res_use_inet6.c (response_ptr_v4, response_ptr_v6): diff --git a/NEWS b/NEWS index 8fbf4241d1..62959274b3 100644 --- a/NEWS +++ b/NEWS @@ -28,6 +28,7 @@ The following bugs are resolved with this release: [21932] Unpaired __resolv_context_get in generic get*_r implementation [21941] powerpc: Restrict xssqrtqp operands to Vector Registers [21972] assert macro requires operator== (int) for its argument type + [22095] resolv: Fix memory leak with OOM during resolv.conf parsing Version 2.26 diff --git a/resolv/res_init.c b/resolv/res_init.c index fa46ce7813..4e1f9fe8de 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -446,6 +446,11 @@ res_vinit_1 (FILE *fp, struct resolv_conf_parser *parser) (&parser->nameserver_list); if (p != NULL) *p = sa; + else + { + free (sa); + return false; + } } continue; }