mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 04:48:06 +01:00
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 <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
1bd9621709
commit
243a1924fa
@@ -33,6 +33,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
@@ -294,7 +295,8 @@ void DispatchEvent(XEvent * event)
|
|||||||
*/
|
*/
|
||||||
static void handle_inotify_events(void)
|
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 */
|
/* Make room for at lease 5 simultaneous events, with path + filenames */
|
||||||
char buff[ (sizeof(struct inotify_event) + NAME_MAX + 1) * 5 ];
|
char buff[ (sizeof(struct inotify_event) + NAME_MAX + 1) * 5 ];
|
||||||
/* Check config only once per read of the event queue */
|
/* 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,
|
eventQLength = read(w_global.inotify.fd_event_queue,
|
||||||
buff, sizeof(buff) );
|
buff, sizeof(buff) );
|
||||||
|
|
||||||
|
if (eventQLength < 0) {
|
||||||
|
wwarning(_("read problem when trying to get INotify event: %s"), strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* check what events occured */
|
/* check what events occured */
|
||||||
/* Should really check wd here too, but for now we only have one watch! */
|
/* Should really check wd here too, but for now we only have one watch! */
|
||||||
while (i < eventQLength) {
|
while (i < eventQLength) {
|
||||||
|
|||||||
Reference in New Issue
Block a user