[Dnsmasq-discuss] [PATCH] Inotify: Ignore backup files created by editors

Andy Hawkins andy at gently.org.uk
Tue Feb 13 09:40:51 GMT 2018


Use strlen to determine the length of the filename returned by
inotify, as in->len refers to the length of the buffer containing
the name, not the length of the name itself.

http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2018q1/011950.html

Signed-off-by: Andy Hawkins <andy at gently.org.uk>
---
 src/inotify.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/inotify.c b/src/inotify.c
index eda1d56..45c730a 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -235,8 +235,8 @@ int inotify_check(time_t now)
 
 	  /* ignore emacs backups and dotfiles */
 	  if (in->len == 0 || 
-	      in->name[in->len - 1] == '~' ||
-	      (in->name[0] == '#' && in->name[in->len - 1] == '#') ||
+	      in->name[strlen(in->name) - 1] == '~' ||
+	      (in->name[0] == '#' && in->name[strlen(in->name) - 1] == '#') ||
 	      in->name[0] == '.')
 	    continue;
 	  
-- 
2.11.0




More information about the Dnsmasq-discuss mailing list