aboutsummaryrefslogtreecommitdiff
path: root/pmult
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-04-18 10:53:19 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2009-04-18 14:07:03 +0300
commitefc22fc1c0eb1b851b2a61227662ad372bcc1fda (patch)
tree4ad0024f4f869d7224033218c61d60dd78055366 /pmult
parent8e51f4c4bcffd7e1610e237eb2be2cb2e9d978e6 (diff)
downloadmailfromd-efc22fc1c0eb1b851b2a61227662ad372bcc1fda.tar.gz
mailfromd-efc22fc1c0eb1b851b2a61227662ad372bcc1fda.tar.bz2
Fix CRLF/LF inconsistencies. Fix bug in SAVEEX/RESTEX.
* mfd/prog.c (instr_restex): Bugfix. Use pop to restore catch addresses. This also fixes the resulting tos value. * mfd/bi_body.m4 (current_message): Use mf_stream_to_message * mfd/bi_sa.m4 (spamd_send_stream): Return int. Recode delimiters to "\r\n". (sa): Check return from spamd_send_stream. Adjust reported stream size. (clamav): Check return from spamd_send_stream. * mfd/bi_sieve.m4 [MAILUTILS_VERSION_NUMBER < 1290]: Remove * mfd/mailfromd.h (env_get_line_count, mf_stream_to_message): New functions. * mfd/prog.c (struct eval_environ.line_count): New member. (env_get_line_count): New function. (env_capture_start): Init eval_environ.line_count (env_capture_write): Recode "\r\n" -> "\r". Update eval_environ.line_count. * mtasim/mtasim.c (send_body): New function. (smtp): Use CRLF as line terminator in message body. * pmult/pmult.c (collect_headers): strip off \r's.
Diffstat (limited to 'pmult')
-rw-r--r--pmult/pmult.c50
1 files changed, 36 insertions, 14 deletions
diff --git a/pmult/pmult.c b/pmult/pmult.c
index fa3c6e97..0bee2f8d 100644
--- a/pmult/pmult.c
+++ b/pmult/pmult.c
@@ -1,5 +1,5 @@
/* This file is part of Mailfromd.
- Copyright (C) 2008 Sergey Poznyakoff
+ Copyright (C) 2008, 2009 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1723,11 +1723,28 @@ rf_body (pmse_ctx_P pmse_ctx, gacopyz_srv_t gsrv, void *data)
}
static int
+flush_buf (struct pmult_priv_data *p, unsigned char *buf, size_t start,
+ size_t end)
+{
+ if (end > start)
+ {
+ int rc = mu_stream_sequential_write (p->hdrstream, buf + start,
+ end - start);
+ if (rc)
+ {
+ mu_error ("%smu_stream_sequential_write: %s",
+ PRIV_SEID_C (p), mu_strerror (rc));
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int
collect_headers (struct pmult_priv_data *p, unsigned char *buf, size_t len,
size_t *poff)
{
- int rc;
- size_t off = 0;
+ size_t start = 0, off = 0;
if (p->state == pmult_msg_state_initial)
{
@@ -1745,7 +1762,10 @@ collect_headers (struct pmult_priv_data *p, unsigned char *buf, size_t len,
for (; off < len; off++)
if (buf[off] == '\r')
{
+ if (flush_buf (p, buf, start, off))
+ return 1;
off++;
+ start = off;
p->state = pmult_msg_state_cr1;
break;
}
@@ -1772,6 +1792,9 @@ collect_headers (struct pmult_priv_data *p, unsigned char *buf, size_t len,
break;
case '\r':
+ if (flush_buf (p, buf, start, off))
+ return 1;
+ start = off + 1;
p->state = pmult_msg_state_cr2;
break;
@@ -1790,8 +1813,11 @@ collect_headers (struct pmult_priv_data *p, unsigned char *buf, size_t len,
case pmult_msg_state_dot:
if (buf[off] == '\r')
{
- p->state = pmult_msg_state_dot_cr;
+ if (flush_buf (p, buf, start, off))
+ return 1;
off++;
+ start = off;
+ p->state = pmult_msg_state_dot_cr;
}
else
p->state = pmult_msg_state_headers;
@@ -1805,19 +1831,16 @@ collect_headers (struct pmult_priv_data *p, unsigned char *buf, size_t len,
}
else
p->state = pmult_msg_state_headers;
-
+ break;
+
default:
abort ();
}
}
- rc = mu_stream_sequential_write (p->hdrstream, buf, off);
- if (rc)
- {
- mu_error ("%smu_stream_sequential_write: %s",
- PRIV_SEID_C (p), mu_strerror (rc));
- return 1;
- }
+ if (flush_buf (p, buf, start, off))
+ return 1;
+
*poff = off;
return 0;
}
@@ -1916,8 +1939,7 @@ pmult_msg_handler (pmse_ctx_P pmse_ctx, unsigned char *buf, size_t len)
if (p->state != pmult_msg_state_body)
{
size_t off;
- int rc = collect_headers (p, buf, len, &off);
- if (rc)
+ if (collect_headers (p, buf, len, &off))
return SMTP_R_ACCEPT; /* Better safe than sorry. */
if (p->state == pmult_msg_state_eom)
process_headers (pmse_ctx, p);

Return to:

Send suggestions and report system problems to the System administrator.