summaryrefslogtreecommitdiff
path: root/lib/libutil/readlabel.c
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2016-08-30 14:44:46 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2016-08-30 14:44:46 +0000
commitcf19f8023d2f381cad286f58b3faf5d19fee29d4 (patch)
tree4f7ded012de4af64edb62811cefa3fbac4969b13 /lib/libutil/readlabel.c
parent06a2db4962987663cb8b269b828429f88ad7f97d (diff)
Use O_CLOEXEC when opening fds local to a function
ok jca@ krw@
Diffstat (limited to 'lib/libutil/readlabel.c')
-rw-r--r--lib/libutil/readlabel.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libutil/readlabel.c b/lib/libutil/readlabel.c
index e2cee311d28..d53820e67ac 100644
--- a/lib/libutil/readlabel.c
+++ b/lib/libutil/readlabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readlabel.c,v 1.13 2015/01/16 16:48:52 deraadt Exp $ */
+/* $OpenBSD: readlabel.c,v 1.14 2016/08/30 14:44:45 guenther Exp $ */
/*
* Copyright (c) 1996, Jason Downs. All rights reserved.
@@ -59,7 +59,7 @@ readlabelfs(char *device, int verbose)
/* Perform disk mapping if device is given as a DUID. */
if (isduid(device, 0)) {
- if ((fd = open("/dev/diskmap", O_RDONLY)) != -1) {
+ if ((fd = open("/dev/diskmap", O_RDONLY|O_CLOEXEC)) != -1) {
bzero(&dm, sizeof(struct dk_diskmap));
strlcpy(rpath, device, sizeof(rpath));
part = rpath[strlen(rpath) - 1];
@@ -105,12 +105,12 @@ readlabelfs(char *device, int verbose)
}
/* If rpath doesn't exist, change that partition back. */
- fd = open(rpath, O_RDONLY);
+ fd = open(rpath, O_RDONLY|O_CLOEXEC);
if (fd < 0) {
if (errno == ENOENT) {
rpath[strlen(rpath) - 1] = part;
- fd = open(rpath, O_RDONLY);
+ fd = open(rpath, O_RDONLY|O_CLOEXEC);
if (fd < 0) {
if (verbose)
warn("%s", rpath);