Only open with O_RDWR if we are actually chaging a report descriptor, other
authormiod <miod@openbsd.org>
Mon, 2 Aug 2010 13:57:32 +0000 (13:57 +0000)
committermiod <miod@openbsd.org>
Mon, 2 Aug 2010 13:57:32 +0000 (13:57 +0000)
operations only need O_RDONLY.
ok blambert@ deraadt@

usr.bin/usbhidctl/usbhid.c

index 896186d..4646dd6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: usbhid.c,v 1.9 2008/10/16 18:37:19 jakemsr Exp $      */
+/*     $OpenBSD: usbhid.c,v 1.10 2010/08/02 13:57:32 miod Exp $        */
 /*      $NetBSD: usbhid.c,v 1.22 2002/02/20 20:30:42 christos Exp $ */
 
 /*
@@ -937,7 +937,7 @@ main(int argc, char **argv)
                dev = devnamebuf;
        }
 
-       hidfd = open(dev, O_RDWR);
+       hidfd = open(dev, wflag ? O_RDWR : O_RDONLY);
        if (hidfd < 0)
                err(1, "%s", dev);