From 287d6bc88d3e07f19a8b83a5818bdd5127d541ed Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Tue, 3 Jun 2025 22:16:50 +0100 Subject: [PATCH] Fix 5846f749e5d878b6b5f7c20f6975bc96b95e4aae Not sure how that bug got in there. Very (un)lucky choice of test data, or last-minute "it'll be fine" modification I guess. It was late, I can't remember. Thanks to Dominik Derrigs for spotting the problem. --- src/inotify.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/inotify.c b/src/inotify.c index e2f2fb3..f70daea 100644 --- a/src/inotify.c +++ b/src/inotify.c @@ -137,14 +137,14 @@ static struct hostsfile *dyndir_addhosts(struct dyndir *dd, char *file) { /* Check if this file is already known in dd->files */ struct hostsfile *ah; - size_t dirlen = sizeof(dd->dname); + size_t dirlen = strlen(dd->dname); /* ah->fname always starts with the string in dd->dname */ for (ah = dd->files; ah; ah = ah->next) - if (ah->fname[dirlen+2] == '/' && - strcmp(&ah->fname[dirlen+3], file) == 0) + if (ah->fname[dirlen] == '/' && + strcmp(&ah->fname[dirlen+1], file) == 0) return ah; - + /* Not known, create new hostsfile record for this dyndir */ if ((ah = whine_malloc(sizeof(struct hostsfile)))) {