From 43d73e3c012db70fb72503f8e645e43960fa3fc1 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Wed, 10 Feb 2021 12:14:51 +0100 Subject: [PATCH] plugins: Use len field from inotify_event to calc dest buffer Signed-off-by: Joachim Wiberg --- plugins/tty.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/tty.c b/plugins/tty.c index c7a99c83..a56fd4f3 100644 --- a/plugins/tty.c +++ b/plugins/tty.c @@ -55,12 +55,14 @@ static void setup(void) static void watcher(void *arg, int fd, int events) { + char buf[EVENT_SIZE]; int len = 0; - char buf[EVENT_SIZE], name[256]; - struct tty *entry; - struct inotify_event *notified = (struct inotify_event *)buf; while ((len = read(fd, buf, sizeof(buf)))) { + struct inotify_event *notified = (struct inotify_event *)buf; + char name[notified->len + 6]; + struct tty *entry; + if (-1 == len) { if (errno == EINVAL) setup();