summaryrefslogtreecommitdiffstats
path: root/src/account/indication_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/account/indication_common.c')
-rw-r--r--src/account/indication_common.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/account/indication_common.c b/src/account/indication_common.c
index 22391e3..88d16a0 100644
--- a/src/account/indication_common.c
+++ b/src/account/indication_common.c
@@ -159,14 +159,20 @@ bool watcher(AccountIndication *ind, void **data)
do {
int len = 0, i = 0;
- if ((len = read(ind->inotify_fd, buffer, BUF_LEN)) < 0) {
+ if ((len = read(ind->inotify_fd, buffer, BUF_LEN)) < 0 || len > (int) BUF_LEN) {
warn("account watcher: error reading from inotify fd: %s", strerror(errno));
watcher_destroy(ind);
watcher_init(ind);
return false;
}
- while (i < len) {
+ while (i + (ssize_t) EVENT_SIZE < len) {
struct inotify_event *event = (struct inotify_event *) &buffer[i];
+ if (i + (ssize_t) EVENT_SIZE + event->len >= len) {
+ error("Unable to create watcher, inotify initialization failed");
+ watcher_destroy(ind);
+ watcher_init(ind);
+ return false;
+ }
switch (event->mask) {
case IN_MODIFY:
case IN_CLOSE_WRITE: