mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-25 12:11:10 +00:00
resolv: Fix file handle leak in __resolv_conf_load [BZ #25429]
res_vinit_1 did not close the stream on errors, only on success. This change moves closing the stream to __resolv_conf_load, for both the success and error cases. Fixes commit89f187a40f
("resolv: Use getline for configuration file reading in res_vinit_1") and commit3f853f22c8
("resolv: Lift domain search list limits [BZ #19569] [BZ #21475]"), where memory allocation was introduced into res_vinit_1. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
parent
9642b85fd0
commit
a1a20f0292
@ -508,7 +508,6 @@ res_vinit_1 (FILE *fp, struct resolv_conf_parser *parser)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
fclose (fp);
|
||||
}
|
||||
if (__glibc_unlikely (nameserver_list_size (&parser->nameserver_list) == 0))
|
||||
{
|
||||
@ -593,6 +592,13 @@ __resolv_conf_load (struct __res_state *preinit)
|
||||
}
|
||||
resolv_conf_parser_free (&parser);
|
||||
|
||||
if (fp != NULL)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
fclose (fp);
|
||||
__set_errno (saved_errno);
|
||||
}
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user