summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2021-04-03 19:20:32 +0200
committerMark Wielaard <[email protected]>2021-04-13 14:45:34 +0200
commitb58516a620c70db026b13f6c36b634d3ae7f1739 (patch)
tree8df9df9baf395189aa2816600788a7bac449e973 /src
parenta8e925ec759712f969166d941b82817e9b68cfb9 (diff)
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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/ar.c3
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 <[email protected]>
+
+ * ar.c (do_oper_insert): Always close newfd.
+
2021-03-03 Mark Wielaard <[email protected]>
* readelf.c (handle_symtab): Sanity check verneed vna_next,
diff --git a/src/ar.c b/src/ar.c
index 66b2c4fd..ab6098f0 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;
}