summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2006-04-23 08:51:25 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2006-04-23 08:51:25 +0000
commit3aa701001d760142f23df111be771f4e75838caa (patch)
tree057a67d9ee32918ac7e73a24e32704ef85835f65
parentba45a09f4293116001cc10dc575e5adc73d3a2ca (diff)
Avoid passing the device file descriptor to executed commands; deraadt@ ok
-rw-r--r--usr.bin/usbhidaction/usbhidaction.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.bin/usbhidaction/usbhidaction.c b/usr.bin/usbhidaction/usbhidaction.c
index d5d5a89abf8..49c30347296 100644
--- a/usr.bin/usbhidaction/usbhidaction.c
+++ b/usr.bin/usbhidaction/usbhidaction.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbhidaction.c,v 1.6 2004/10/27 18:16:57 jaredy Exp $ */
+/* $OpenBSD: usbhidaction.c,v 1.7 2006/04/23 08:51:24 fgsch Exp $ */
/* $NetBSD: usbhidaction.c,v 1.7 2002/01/18 14:38:59 augustss Exp $ */
/*
@@ -140,6 +140,11 @@ main(int argc, char **argv)
fd = open(dev, O_RDWR);
if (fd < 0)
err(1, "%s", dev);
+
+ /* Avoid passing the device file descriptor to executed commands */
+ if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
+ err(1, "fcntl(F_SETFD, FD_CLOEXEC)");
+
if (ioctl(fd, USB_GET_REPORT_ID, &reportid) < 0)
reportid = -1;
repd = hid_get_report_desc(fd);