diff options
author | Mark Wielaard <mark@klomp.org> | 2021-04-03 19:20:32 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2021-04-13 14:45:34 +0200 |
commit | b58516a620c70db026b13f6c36b634d3ae7f1739 (patch) | |
tree | 8df9df9baf395189aa2816600788a7bac449e973 | |
parent | a8e925ec759712f969166d941b82817e9b68cfb9 (diff) | |
download | elfutils-b58516a620c70db026b13f6c36b634d3ae7f1739.tar.gz |
ar: Always close newfd in do_oper_insert.
newfd is normally created by mkstemp given the original fd exists.
Otherwise it will created by open from arfname. In the second case
newfd might not get closed. Preventd this by always trying to close
it after errout.
Signed-off-by: Mark Wielaard <mark@klomp.org>
-rw-r--r-- | src/ChangeLog | 4 | ||||
-rw-r--r-- | src/ar.c | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 14cd6cac..f0eee7a8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2021-04-03 Mark Wielaard <mark@klomp.org> + + * ar.c (do_oper_insert): Always close newfd. + 2021-03-03 Mark Wielaard <mark@klomp.org> * readelf.c (handle_symtab): Sanity check verneed vna_next, @@ -1566,6 +1566,9 @@ do_oper_insert (int oper, const char *arfname, char **argv, int argc, if (fd != -1) close (fd); + if (newfd != -1) + close (newfd); + return status; } |