From 243a1924fa61f4c698f09b156db0398834b50d0e Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 29 Nov 2014 16:35:25 +0100 Subject: [PATCH] wmaker: fix signedness of variable (Coverity #50082, #50222) Coverity complain that there can be security issues because the variable 'i' is being modified using untrusted data (coming from a file). This is probably pessimistic, because in the present case we're talking with the kernel. Using the correct signedness for the variable should however keep us safe, and (I hope) make Coverity happy. Took opportunity to include an error message in case of read problem because it can help to debug. Signed-off-by: Christophe CURIS --- src/event.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/event.c b/src/event.c index bc590fe5..9a8a3e3f 100644 --- a/src/event.c +++ b/src/event.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -294,7 +295,8 @@ void DispatchEvent(XEvent * event) */ static void handle_inotify_events(void) { - ssize_t eventQLength, i = 0; + ssize_t eventQLength; + size_t i = 0; /* Make room for at lease 5 simultaneous events, with path + filenames */ char buff[ (sizeof(struct inotify_event) + NAME_MAX + 1) * 5 ]; /* Check config only once per read of the event queue */ @@ -310,6 +312,11 @@ static void handle_inotify_events(void) eventQLength = read(w_global.inotify.fd_event_queue, buff, sizeof(buff) ); + if (eventQLength < 0) { + wwarning(_("read problem when trying to get INotify event: %s"), strerror(errno)); + return; + } + /* check what events occured */ /* Should really check wd here too, but for now we only have one watch! */ while (i < eventQLength) { -- 2.11.4.GIT