From: Mark Wielaard Date: Sat, 3 Apr 2021 17:20:32 +0000 (+0200) Subject: ar: Always close newfd in do_oper_insert. X-Git-Tag: elfutils-0.184~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b58516a620c70db026b13f6c36b634d3ae7f1739;p=thirdparty%2Felfutils.git 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 --- diff --git a/src/ChangeLog b/src/ChangeLog index 14cd6cacc..f0eee7a8a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2021-04-03 Mark Wielaard + + * ar.c (do_oper_insert): Always close newfd. + 2021-03-03 Mark Wielaard * readelf.c (handle_symtab): Sanity check verneed vna_next, diff --git a/src/ar.c b/src/ar.c index 66b2c4fdc..ab6098f03 100644 --- a/src/ar.c +++ b/src/ar.c @@ -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; }