From 12952cdddb0465093c3bd869bc28c677dd78a53b Mon Sep 17 00:00:00 2001 From: Stephane Lee Date: Mon, 13 Jan 2020 15:46:36 -0800 Subject: [PATCH] Fix ioctl FIONREAD call parameters to use int instead of size_t Test: Ensure that calls to inotify_cb succeed; Ensure charger does not crash Change-Id: I9a7ca304057313c74ef02fd97223d0ed570c6206 --- minui/events.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/minui/events.cpp b/minui/events.cpp index f331ed68..87f81122 100644 --- a/minui/events.cpp +++ b/minui/events.cpp @@ -90,9 +90,11 @@ static int inotify_cb(int fd, __unused uint32_t epevents) { // The inotify will put one or several complete events. // Should not read part of one event. - size_t event_len; - int ret = ioctl(fd, FIONREAD, &event_len); + int event_len_int; + int ret = ioctl(fd, FIONREAD, &event_len_int); if (ret != 0) return -1; + if (event_len_int < 0) return -1; + size_t event_len = event_len_int; std::unique_ptr dir(opendir(INPUT_DEV_DIR), closedir); if (!dir) {