|
|
a2cf7d |
From: Florian Weimer <fweimer@redhat.com>
|
|
|
a2cf7d |
Date: Tue, 21 Jan 2020 16:11:01 +0000 (+0100)
|
|
|
a2cf7d |
Subject: resolv: Fix file handle leak in __resolv_conf_load [BZ #25429]
|
|
|
a2cf7d |
X-Git-Url: https://sourceware.org/git/?p=glibc.git;a=commitdiff_plain;h=a1a20f029299dc27170912bb9233070c8403444d
|
|
|
a2cf7d |
|
|
|
a2cf7d |
resolv: Fix file handle leak in __resolv_conf_load [BZ #25429]
|
|
|
a2cf7d |
|
|
|
a2cf7d |
res_vinit_1 did not close the stream on errors, only on success.
|
|
|
a2cf7d |
This change moves closing the stream to __resolv_conf_load, for both
|
|
|
a2cf7d |
the success and error cases.
|
|
|
a2cf7d |
|
|
|
a2cf7d |
Fixes commit 89f187a40fc0ad4e22838526bfe34d73f758b776 ("resolv: Use
|
|
|
a2cf7d |
getline for configuration file reading in res_vinit_1") and commit
|
|
|
a2cf7d |
3f853f22c87f0b671c0366eb290919719fa56c0e ("resolv: Lift domain search
|
|
|
a2cf7d |
list limits [BZ #19569] [BZ #21475]"), where memory allocation was
|
|
|
a2cf7d |
introduced into res_vinit_1.
|
|
|
a2cf7d |
|
|
|
a2cf7d |
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
a2cf7d |
---
|
|
|
a2cf7d |
|
|
|
a2cf7d |
diff --git a/resolv/res_init.c b/resolv/res_init.c
|
|
|
a2cf7d |
index 95dce098aa..09345718cd 100644
|
|
|
a2cf7d |
--- a/resolv/res_init.c
|
|
|
a2cf7d |
+++ b/resolv/res_init.c
|
|
|
a2cf7d |
@@ -508,7 +508,6 @@ res_vinit_1 (FILE *fp, struct resolv_conf_parser *parser)
|
|
|
a2cf7d |
continue;
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
- fclose (fp);
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
if (__glibc_unlikely (nameserver_list_size (&parser->nameserver_list) == 0))
|
|
|
a2cf7d |
{
|
|
|
a2cf7d |
@@ -593,6 +592,13 @@ __resolv_conf_load (struct __res_state *preinit)
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
resolv_conf_parser_free (&parser);
|
|
|
a2cf7d |
|
|
|
a2cf7d |
+ if (fp != NULL)
|
|
|
a2cf7d |
+ {
|
|
|
a2cf7d |
+ int saved_errno = errno;
|
|
|
a2cf7d |
+ fclose (fp);
|
|
|
a2cf7d |
+ __set_errno (saved_errno);
|
|
|
a2cf7d |
+ }
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
return conf;
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
|