From d6390244ad99454e9ed526fbe982a65cc871e0c1 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 7 Mar 2021 09:53:40 +0100 Subject: [PATCH] Fix possible out-of-bounds read in inotify_event parser Found by Coverity Scan. Signed-off-by: Joachim Wiberg --- plugins/pidfile.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/pidfile.c b/plugins/pidfile.c index 20e11afc..3bd1a7a9 100644 --- a/plugins/pidfile.c +++ b/plugins/pidfile.c @@ -163,7 +163,13 @@ static void pidfile_callback(void *arg, int fd, int events) for (off = 0; off < sz; off += sizeof(*ev) + ev->len) { struct iwatch_path *iwp; + if (off + sizeof(*ev) >= sizeof(ev_buf)) + break; + ev = (struct inotify_event *)&ev_buf[off]; + if (off + sizeof(*ev) + ev->len >= sizeof(ev_buf)) + break; + if (!ev->mask) continue;