summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2017-09-19 08:28:58 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2017-09-19 08:28:58 +0000
commit0025421be784b59ea032a49e481eb91dc044c3ec (patch)
tree79254426b60580e10abbacc52dc4bc90bdddcec4
parentdb27b941576ea243babbf1718362326d0ffc082d (diff)
fix fd leaks in error paths
ok mpi@
-rw-r--r--usr.bin/ctfconv/ctfconv.c4
-rw-r--r--usr.bin/ctfdump/ctfdump.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/ctfconv/ctfconv.c b/usr.bin/ctfconv/ctfconv.c
index 1d3b3921c7d..89af54a7131 100644
--- a/usr.bin/ctfconv/ctfconv.c
+++ b/usr.bin/ctfconv/ctfconv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ctfconv.c,v 1.8 2017/08/29 21:10:20 deraadt Exp $ */
+/* $OpenBSD: ctfconv.c,v 1.9 2017/09/19 08:28:57 jsg Exp $ */
/*
* Copyright (c) 2016-2017 Martin Pieuchot
@@ -180,10 +180,12 @@ convert(const char *path)
}
if (fstat(fd, &st) == -1) {
warn("fstat %s", path);
+ close(fd);
return 1;
}
if ((uintmax_t)st.st_size > SIZE_MAX) {
warnx("file too big to fit memory");
+ close(fd);
return 1;
}
diff --git a/usr.bin/ctfdump/ctfdump.c b/usr.bin/ctfdump/ctfdump.c
index 8eec639bb48..060cc117f0c 100644
--- a/usr.bin/ctfdump/ctfdump.c
+++ b/usr.bin/ctfdump/ctfdump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ctfdump.c,v 1.5 2017/08/29 21:10:20 deraadt Exp $ */
+/* $OpenBSD: ctfdump.c,v 1.6 2017/09/19 08:28:57 jsg Exp $ */
/*
* Copyright (c) 2016 Martin Pieuchot <mpi@openbsd.org>
@@ -139,10 +139,12 @@ dump(const char *path, uint8_t flags)
}
if (fstat(fd, &st) == -1) {
warn("fstat");
+ close(fd);
return 1;
}
if ((uintmax_t)st.st_size > SIZE_MAX) {
warnx("file too big to fit memory");
+ close(fd);
return 1;
}