Re: [Dnsmasq-discuss] [PATCH] Inotify: Ignore backup files created by editors
Hi, In article , Andy Hawkins wrote: > I'll take a look at your version of the code in git and see how it looks > compared to mine. Ok, things are a bit clearer after looking at the actual commit. My only comment (and it's a fairly personal one) is that I generally dislike seeing variable assignments inside if statements. However, I can see the reason for doing it in this case, as if you carried out the strlen outside the 'if', then you'd need to put that in an 'if' of its own, checking that in->len wasn't zero. Thanks for including the fix however, appreciated. What are the chances of this ending up in a package in the current debian stable? Thanks again Andy ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] Inotify: Ignore backup files created by editors
Hi, In article <0f10b5dc-7504-a92a-824d-ecc091b00...@thekelleys.org.uk>, Simon Kelley wrote: > Patch applied, with two modifications. > > 1) I added a check for strlen(in->name) not being zero. I don't know if > inotify could give us a zero-length filename, but if it did, we'd make > an out-of-bounds array reference to in->name[-1]. I also saved the > return from strlen(in->name) in a variable, rather than call strlen > three times. > > 2) Move the resolv-file test to after the dotfiles test. Only relevant > if someone configures a resolv file name which looks like an editor > backup file, but at least in's consistent. Also allows removal of a > now-redundant in->len == 0 test. Is it possible for in->len to be zero? The man page for inotify does say the name is optional, so I assumed that this was what that test was checking for? I'll take a look at your version of the code in git and see how it looks compared to mine. Thanks Andy ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] Inotify: Ignore backup files created by editors
Patch applied, with two modifications. 1) I added a check for strlen(in->name) not being zero. I don't know if inotify could give us a zero-length filename, but if it did, we'd make an out-of-bounds array reference to in->name[-1]. I also saved the return from strlen(in->name) in a variable, rather than call strlen three times. 2) Move the resolv-file test to after the dotfiles test. Only relevant if someone configures a resolv file name which looks like an editor backup file, but at least in's consistent. Also allows removal of a now-redundant in->len == 0 test. Cheers, Simon. On 13/02/18 09:40, Andy Hawkins wrote: > 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 ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
[Dnsmasq-discuss] [PATCH] Inotify: Ignore backup files created by editors
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 --- 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 ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss