diff options
author | Philip Hazel <ph10@hermes.cam.ac.uk> | 2007-06-22 14:38:58 +0000 |
---|---|---|
committer | Philip Hazel <ph10@hermes.cam.ac.uk> | 2007-06-22 14:38:58 +0000 |
commit | d677b2f22abb3eb268e5cb15e4710ff5063049fe (patch) | |
tree | de20d4e3083cb4ca8a59fc52dbcffa769ef25520 /src | |
parent | 3c2238744f437aba7215008aed259e4c5af2c57e (diff) |
Added $max_received_linelength.
Diffstat (limited to 'src')
-rw-r--r-- | src/exim_monitor/em_globals.c | 3 | ||||
-rw-r--r-- | src/src/expand.c | 3 | ||||
-rw-r--r-- | src/src/globals.c | 3 | ||||
-rw-r--r-- | src/src/globals.h | 3 | ||||
-rw-r--r-- | src/src/receive.c | 50 | ||||
-rw-r--r-- | src/src/spool_in.c | 5 | ||||
-rw-r--r-- | src/src/spool_out.c | 3 |
7 files changed, 57 insertions, 13 deletions
diff --git a/src/exim_monitor/em_globals.c b/src/exim_monitor/em_globals.c index ffd3b1973..f71014997 100644 --- a/src/exim_monitor/em_globals.c +++ b/src/exim_monitor/em_globals.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/exim_monitor/em_globals.c,v 1.11 2007/01/08 10:50:17 ph10 Exp $ */ +/* $Cambridge: exim/src/exim_monitor/em_globals.c,v 1.12 2007/06/22 14:38:58 ph10 Exp $ */ /************************************************* * Exim Monitor * @@ -163,6 +163,7 @@ BOOL log_timezone = FALSE; uschar *spam_score_int = NULL; #endif +int max_received_linelength= 0; int message_age = 0; uschar *message_id; uschar *message_id_external; diff --git a/src/src/expand.c b/src/src/expand.c index abff94996..e56f86678 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/expand.c,v 1.86 2007/06/14 14:18:19 ph10 Exp $ */ +/* $Cambridge: exim/src/src/expand.c,v 1.87 2007/06/22 14:38:58 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -453,6 +453,7 @@ static var_entry var_table[] = { #ifdef WITH_CONTENT_SCAN { "malware_name", vtype_stringptr, &malware_name }, #endif + { "max_received_linelength", vtype_int, &max_received_linelength }, { "message_age", vtype_int, &message_age }, { "message_body", vtype_msgbody, &message_body }, { "message_body_end", vtype_msgbody_end, &message_body_end }, diff --git a/src/src/globals.c b/src/src/globals.c index 7d34c6699..f12e8eb34 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/globals.c,v 1.74 2007/06/18 13:57:50 ph10 Exp $ */ +/* $Cambridge: exim/src/src/globals.c,v 1.75 2007/06/22 14:38:58 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -743,6 +743,7 @@ uschar *mailstore_basename = NULL; #ifdef WITH_CONTENT_SCAN uschar *malware_name = NULL; /* Virus Name */ #endif +int max_received_linelength= 0; int max_username_length = 0; int message_age = 0; uschar *message_body = NULL; diff --git a/src/src/globals.h b/src/src/globals.h index ce43922c0..f80e88b7b 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/globals.h,v 1.54 2007/06/14 14:18:19 ph10 Exp $ */ +/* $Cambridge: exim/src/src/globals.h,v 1.55 2007/06/22 14:38:58 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -432,6 +432,7 @@ extern uschar *mailstore_basename; /* For mailstore deliveries */ #ifdef WITH_CONTENT_SCAN extern uschar *malware_name; /* Name of virus or malware ("W32/Klez-H") */ #endif +extern int max_received_linelength;/* What it says */ extern int max_username_length; /* For systems with broken getpwnam() */ extern int message_age; /* In seconds */ extern uschar *message_body; /* Start of message body for filter */ diff --git a/src/src/receive.c b/src/src/receive.c index e4c82d2fa..ee95cc981 100644 --- a/src/src/receive.c +++ b/src/src/receive.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/receive.c,v 1.37 2007/04/16 10:31:58 ph10 Exp $ */ +/* $Cambridge: exim/src/src/receive.c,v 1.38 2007/06/22 14:38:58 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -564,6 +564,7 @@ read_message_data(FILE *fout) { int ch_state; register int ch; +register int linelength = 0; /* Handle the case when only EOF terminates the message */ @@ -576,6 +577,9 @@ if (!dot_ends) if (ch == 0) body_zerocount++; if (last_ch == '\r' && ch != '\n') { + if (linelength > max_received_linelength) + max_received_linelength = linelength; + linelength = 0; if (fputc('\n', fout) == EOF) return END_WERROR; message_size++; body_linecount++; @@ -583,12 +587,21 @@ if (!dot_ends) if (ch == '\r') continue; if (fputc(ch, fout) == EOF) return END_WERROR; - if (ch == '\n') body_linecount++; + if (ch == '\n') + { + if (linelength > max_received_linelength) + max_received_linelength = linelength; + linelength = 0; + body_linecount++; + } + else linelength++; if (++message_size > thismessage_size_limit) return END_SIZE; } if (last_ch != '\n') { + if (linelength > max_received_linelength) + max_received_linelength = linelength; if (fputc('\n', fout) == EOF) return END_WERROR; message_size++; body_linecount++; @@ -608,25 +621,37 @@ while ((ch = (RECEIVE_GETC)()) != EOF) { case 0: /* Normal state (previous char written) */ if (ch == '\n') - { body_linecount++; ch_state = 1; } + { + body_linecount++; + if (linelength > max_received_linelength) + max_received_linelength = linelength; + linelength = -1; + ch_state = 1; + } else if (ch == '\r') { ch_state = 2; continue; } break; case 1: /* After written "\n" */ if (ch == '.') { ch_state = 3; continue; } - if (ch != '\n') ch_state = 0; + if (ch != '\n') ch_state = 0; else linelength = -1; break; case 2: body_linecount++; /* After unwritten "\r" */ + if (linelength > max_received_linelength) + max_received_linelength = linelength; if (ch == '\n') - { ch_state = 1; } + { + ch_state = 1; + linelength = -1; + } else { if (message_size++, fputc('\n', fout) == EOF) return END_WERROR; if (ch == '\r') continue; ch_state = 0; + linelength = 0; } break; @@ -634,6 +659,7 @@ while ((ch = (RECEIVE_GETC)()) != EOF) if (ch == '\n') return END_DOT; if (ch == '\r') { ch_state = 4; continue; } message_size++; + linelength++; if (fputc('.', fout) == EOF) return END_WERROR; ch_state = 0; break; @@ -648,6 +674,7 @@ while ((ch = (RECEIVE_GETC)()) != EOF) break; } + linelength++; if (fputc(ch, fout) == EOF) return END_WERROR; if (++message_size > thismessage_size_limit) return END_SIZE; } @@ -1263,6 +1290,7 @@ int header_size = 256; int start, end, domain, size, sptr; int id_resolution; int had_zero = 0; +int prevlines_length = 0; register int ptr = 0; @@ -1343,13 +1371,14 @@ data_fd = -1; spool_name[0] = 0; message_size = 0; warning_count = 0; -received_count = 1; /* For the one we will add */ +received_count = 1; /* For the one we will add */ if (thismessage_size_limit <= 0) thismessage_size_limit = INT_MAX; /* While reading the message, the following counts are computed. */ -message_linecount = body_linecount = body_zerocount = 0; +message_linecount = body_linecount = body_zerocount = + max_received_linelength = 0; #ifdef EXPERIMENTAL_DOMAINKEYS /* Call into DK to set up the context. Check if DK is to be run are carried out @@ -1585,6 +1614,12 @@ for (;;) receive_linecount++; message_linecount++; + /* Keep track of maximum line length */ + + if (ptr - prevlines_length > max_received_linelength) + max_received_linelength = ptr - prevlines_length; + prevlines_length = ptr + 1; + /* Now put in the terminating newline. There is always space for at least two more characters. */ @@ -1813,6 +1848,7 @@ for (;;) next->text = store_get(header_size); ptr = 0; had_zero = 0; + prevlines_length = 0; } /* Continue, starting to read the next header */ /* At this point, we have read all the headers into a data structure in main diff --git a/src/src/spool_in.c b/src/src/spool_in.c index b4506c8af..a0fdcf96c 100644 --- a/src/src/spool_in.c +++ b/src/src/spool_in.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/spool_in.c,v 1.19 2007/01/08 10:50:18 ph10 Exp $ */ +/* $Cambridge: exim/src/src/spool_in.c,v 1.20 2007/06/22 14:38:58 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -255,6 +255,7 @@ interface_address = NULL; interface_port = 0; local_error_message = FALSE; local_scan_data = NULL; +max_received_linelength = 0; message_linecount = 0; received_protocol = NULL; received_count = 0; @@ -518,6 +519,8 @@ for (;;) case 'm': if (Ustrcmp(p, "anual_thaw") == 0) deliver_manual_thaw = TRUE; + else if (Ustrncmp(p, "ax_received_linelength", 22) == 0) + max_received_linelength = Uatoi(big_buffer + 24); break; case 'N': diff --git a/src/src/spool_out.c b/src/src/spool_out.c index 724b00e44..b2119f834 100644 --- a/src/src/spool_out.c +++ b/src/src/spool_out.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/spool_out.c,v 1.13 2007/01/22 16:29:54 ph10 Exp $ */ +/* $Cambridge: exim/src/src/spool_out.c,v 1.14 2007/06/22 14:38:58 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -198,6 +198,7 @@ tree_walk(acl_var_m, &acl_var_write, f); /* Now any other data that needs to be remembered. */ fprintf(f, "-body_linecount %d\n", body_linecount); +fprintf(f, "-max_received_linelength %d\n", max_received_linelength); if (body_zerocount > 0) fprintf(f, "-body_zerocount %d\n", body_zerocount); |