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.
This commit is contained in:
Simon Kelley
2025-06-03 22:16:50 +01:00
parent c378d2c1de
commit 287d6bc88d

View File

@@ -137,12 +137,12 @@ static struct hostsfile *dyndir_addhosts(struct dyndir *dd, char *file)
{ {
/* Check if this file is already known in dd->files */ /* Check if this file is already known in dd->files */
struct hostsfile *ah; 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 */ /* ah->fname always starts with the string in dd->dname */
for (ah = dd->files; ah; ah = ah->next) for (ah = dd->files; ah; ah = ah->next)
if (ah->fname[dirlen+2] == '/' && if (ah->fname[dirlen] == '/' &&
strcmp(&ah->fname[dirlen+3], file) == 0) strcmp(&ah->fname[dirlen+1], file) == 0)
return ah; return ah;
/* Not known, create new hostsfile record for this dyndir */ /* Not known, create new hostsfile record for this dyndir */