summaryrefslogtreecommitdiff
path: root/libexec/spamd/spamd.c
diff options
context:
space:
mode:
authorDaniel Hartmeier <dhartmei@cvs.openbsd.org>2004-04-02 23:48:36 +0000
committerDaniel Hartmeier <dhartmei@cvs.openbsd.org>2004-04-02 23:48:36 +0000
commit0a5f0e8a9d711e5f64a84f617cd0507b83d9b1f6 (patch)
tree89d28df53444f4ce59653eb0695733a204146686 /libexec/spamd/spamd.c
parent5e1db24b8318e57829cec39820e29fe864012666 (diff)
nextstate() can get passed a read(2) chunk containing multiple lines,
so separate lines before logging headers/body. doesn't make logging more verbose, just fixes the case where chunks contain multiple lines. ok beck@
Diffstat (limited to 'libexec/spamd/spamd.c')
-rw-r--r--libexec/spamd/spamd.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/libexec/spamd/spamd.c b/libexec/spamd/spamd.c
index 5f450a4a833..0eebe3d673d 100644
--- a/libexec/spamd/spamd.c
+++ b/libexec/spamd/spamd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spamd.c,v 1.64 2004/03/17 14:42:20 beck Exp $ */
+/* $OpenBSD: spamd.c,v 1.65 2004/04/02 23:48:35 dhartmei Exp $ */
/*
* Copyright (c) 2002 Theo de Raadt. All rights reserved.
@@ -741,26 +741,34 @@ nextstate(struct con *cp)
cp->ol = strlen(cp->op);
cp->w = t + cp->stutter;
break;
- case 60:
- if (!strcmp(cp->ibuf, ".") ||
- (cp->data_body && ++cp->data_lines >= 10)) {
- cp->laststate = cp->state;
- cp->state = 98;
- goto done;
- }
- if (!cp->data_body && !*cp->ibuf)
- cp->data_body = 1;
- if (verbose && cp->data_body && *cp->ibuf)
- syslog_r(LOG_DEBUG, &sdata, "%s: Body: %s", cp->addr,
- cp->ibuf);
- else if (verbose && (match(cp->ibuf, "FROM:") ||
- match(cp->ibuf, "TO:") || match(cp->ibuf, "SUBJECT:")))
- syslog_r(LOG_INFO, &sdata, "%s: %s", cp->addr,
- cp->ibuf);
+ case 60: {
+ char *p, *q;
+
+ for (p = q = cp->ibuf; q <= cp->ip; ++q)
+ if (*q == '\r' || *q == '\n' || q == cp->ip) {
+ *q++ = 0;
+ if (!strcmp(p, ".") ||
+ (cp->data_body && ++cp->data_lines >= 10)) {
+ cp->laststate = cp->state;
+ cp->state = 98;
+ goto done;
+ }
+ if (!cp->data_body && !*p)
+ cp->data_body = 1;
+ if (verbose && cp->data_body && *p)
+ syslog_r(LOG_DEBUG, &sdata, "%s: "
+ "Body: %s", cp->addr, p);
+ else if (verbose && (match(p, "FROM:") ||
+ match(p, "TO:") || match(p, "SUBJECT:")))
+ syslog_r(LOG_INFO, &sdata, "%s: %s",
+ cp->addr, p);
+ p = q;
+ }
cp->ip = cp->ibuf;
cp->il = sizeof(cp->ibuf) - 1;
cp->r = t;
break;
+ }
done:
case 98:
doreply(cp);