Thought i'd help out testing the new "NOTYET" feature of qmail-reply
and found a couple of bugs (i think).
First, in recent() there looks to be an infinite loop if the
.qmail-reply.db already contains a sender address and an e-mail
comes in from a different sender.
Also, recent_update seems to always drop the first address in the db
when adding a new address.
A couple of patches are attached. The recent() patch (reply-r.patch)
just adds another 1 to i so the loop can exit, and the
recent_update() patch (reply-ru.patch) compares timestamps and drops
any addresses that are past their timeout period.
These have only received minimal testing, so patcher beware ;)
-neil
--- qmail-reply.org Mon Jan 20 23:56:45 2003
+++ qmail-reply.c Mon Jan 20 23:56:58 2003
@@ -235,7 +235,7 @@
}
slen = rs.len; s = rs.s;
- for (i = 0; i < slen; i += str_len(s+i)) {
+ for (i = 0; i < slen; i += (str_len(s+i)+1)) {
if (case_diffb(buf, len, s+i) == 0) {
/* match found, look at timeval */
rsmatch = i; i += len;
--- qmail-reply.org Mon Jan 20 23:57:32 2003
+++ qmail-reply.c Mon Jan 20 23:57:40 2003
@@ -268,6 +268,7 @@
unsigned long pid, time;
int fd, loop, size, slen, i;
substdio ss;
+ datetime_sec last;
s = rs.s; slen = rs.len;
size = slen + len + 10;
@@ -301,7 +302,12 @@
substdio_fdbuf(&ss, write, fd, rsoutbuf, sizeof(rsoutbuf));
for (i = 0; i < slen; i += str_len(s+i) + 1) {
- if (rs.s+rsmatch == s+i) continue;
+ t = s+i;
+ while (*t && (*t != ':')) t++;
+ if (*t == ':') {
+ last = get_stamp(t+1);
+ if (last + timeout < time) continue;
+ }
if (substdio_puts(&ss, s+i) == -1) goto fail;
if (substdio_put(&ss, "\n", 1) == -1) goto fail;
}