From 38e9f2320ad711303f168c19be259d89ae74df20 Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Fri, 24 Aug 2018 12:16:17 -0700 Subject: [PATCH] getevent: O_RDWR -> O_RDONLY | O_CLOEXEC No need to open the device read write. Just open it read-only. This is a partial redo of https://android-review.googlesource.com/c/platform/system/core/+/334583 which was reverted in https://android-review.googlesource.com/c/platform/system/core/+/342483 Bug: 30861057 Test: ran getevent, saw correct output, played with device Change-Id: I426efd68f39dcd97d3ee23c13ed1a9ed96cb4c2e --- toolbox/getevent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolbox/getevent.c b/toolbox/getevent.c index e6def6bae..39033ad4d 100644 --- a/toolbox/getevent.c +++ b/toolbox/getevent.c @@ -321,7 +321,7 @@ static int open_device(const char *device, int print_flags) char idstr[80]; struct input_id id; - fd = open(device, O_RDWR); + fd = open(device, O_RDONLY | O_CLOEXEC); if(fd < 0) { if(print_flags & PRINT_DEVICE_ERRORS) fprintf(stderr, "could not open %s, %s\n", device, strerror(errno));