Avoid double-closing an fd if elf_begin() fails.

Reported by:	Miles Ohlrich <miles.ohlrich@isilon.com>
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Mark Johnston 2017-03-22 18:14:55 +00:00
parent 78b83a1ea1
commit 48da4e2024
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=315727

View file

@ -275,10 +275,8 @@ rtld_syms(rd_agent_t *rdap, const char *rtldpath, u_long base)
if (elf_version(EV_CURRENT) == EV_NONE)
goto err;
e = elf_begin(fd, ELF_C_READ, NULL);
if (e == NULL) {
close(fd);
if (e == NULL)
goto err;
}
scn = NULL;
while ((scn = elf_nextscn(e, scn)) != NULL) {