Added $max_received_linelength.
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Fri, 22 Jun 2007 14:38:58 +0000 (14:38 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Fri, 22 Jun 2007 14:38:58 +0000 (14:38 +0000)
25 files changed:
doc/doc-txt/ChangeLog
doc/doc-txt/NewStuff
src/exim_monitor/em_globals.c
src/src/expand.c
src/src/globals.c
src/src/globals.h
src/src/receive.c
src/src/spool_in.c
src/src/spool_out.c
test/scripts/0000-Basic/0542
test/stdout/0035
test/stdout/0245
test/stdout/0250
test/stdout/0254
test/stdout/0311
test/stdout/0338
test/stdout/0377
test/stdout/0378
test/stdout/0379
test/stdout/0389
test/stdout/0488
test/stdout/0490
test/stdout/0514
test/stdout/0542
test/stdout/3415

index b8b1e9609aa58d0bee12989e18adfbd30342538f..7c74094302dabfd960e345a39a196048179858fe 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.516 2007/06/20 14:13:39 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.517 2007/06/22 14:38:58 ph10 Exp $
 
 Change log file for Exim from version 4.21
 -------------------------------------------
@@ -67,6 +67,8 @@ PH/09 Tidied the code for creating ratelimiting keys, creating them explicitly
 
 PH/10 Added the /noupdate option to the ratelimit ACL condition.
 
+PH/11 Added $max_received_linelength.
+
 
 Exim version 4.67
 -----------------
index f6cbf54c3f5b6d7b49808591ff403d6a6aab7361..547534ad6c7cc45d322e2c0fa88802fce16b6f22 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/NewStuff,v 1.151 2007/06/20 14:13:39 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/NewStuff,v 1.152 2007/06/22 14:38:58 ph10 Exp $
 
 New Features in Exim
 --------------------
@@ -74,6 +74,10 @@ Version 4.68
 
       accept
 
+ 6. The variable $max_received_linelength contains the number of bytes in the
+    longest line that was received as part of the message, not counting the
+    line termination character(s).
+
 
 Version 4.67
 ------------
index ffd3b19733c07c30d2ef6ad87f20bb72f815f9da..f7101499742eab96eea890b2653d60d2a16bc956 100644 (file)
@@ -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;
index abff94996f9fc3e54954251af1bd933df156a0ef..e56f866785b0fb5a15f579c4bc68b4325b18852f 100644 (file)
@@ -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 },
index 7d34c66994d34eefe94a0a966104eff251e5f4ef..f12e8eb3459a109c18a975a8719fc374636c664c 100644 (file)
@@ -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;
index ce43922c01b3edf8bb5d3caf4f3f7bfc22956228..f80e88b7b9d0b859eaaf9636169d0e240db7b872 100644 (file)
@@ -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 */
index e4c82d2fa7e7087e31fdaf6e822f7e78f3f24f1f..ee95cc98120aea90b184c9a9bc76a52bb6ca2748 100644 (file)
@@ -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
index b4506c8aff022186d14c2d9394ed5af752674ba5..a0fdcf96c294a902f203d3303cbee2c012a124c2 100644 (file)
@@ -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':
index 724b00e44b2db381ea535601d1bd52ea5f91eeb4..b2119f8349cd7ad35d8a557b10e094c1236ad85d 100644 (file)
@@ -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);
 
index da2b9e7684722be5b66579f5c1665a5a6d30662b..92f1f607e6a1ec9d4e7e297ff0b2c28b97bd4a74 100644 (file)
@@ -4,7 +4,7 @@ From: Himself <himself@there.tld>
 To: Yourself <you@here.tld>
 Subject: The subject is not the object
 
-This is the body of the message.
+This is the body of the message. Make the line longer than any header.
 ****
 sudo exim -be -Mset $msg1
 From: $h_from:
@@ -13,6 +13,7 @@ message_body_size=$message_body_size
 message_size=$message_size
 message_id=$message_id
 message_exim_id=$message_exim_id
+max_received_linelength=$max_received_linelength
 recipients=$recipients
 ****
 write test-data
@@ -32,6 +33,7 @@ message_body_size=$message_body_size
 message_exim_id=$message_exim_id
 message_linecount=$message_linecount
 message_body_linecount=$body_linecount
+max_received_linelength=$max_received_linelength
 headers -----------------
 $message_headers
 
index 15cac0b0f7b46653fcdea3280cbc1aec9546d5e9..6b5928b776a2154c371972f03c5472852bdc5177 100644 (file)
@@ -143,6 +143,7 @@ ddddddddd 0
 -interface_address 127.0.0.1.1225
 -received_protocol esmtp
 -body_linecount 0
+-max_received_linelength 0
 -deliver_firsttime
 XX
 1
@@ -162,6 +163,7 @@ ddddddddd 0
 -interface_address 127.0.0.1.1225
 -received_protocol esmtp
 -body_linecount 0
+-max_received_linelength 0
 -deliver_firsttime
 XX
 1
@@ -184,6 +186,7 @@ ddddddddd 0
 -interface_address 127.0.0.1.1225
 -received_protocol esmtp
 -body_linecount 0
+-max_received_linelength 0
 -deliver_firsttime
 XX
 1
@@ -204,6 +207,7 @@ ddddddddd 0
 -interface_address 127.0.0.1.1225
 -received_protocol esmtp
 -body_linecount 0
+-max_received_linelength 25
 -deliver_firsttime
 XX
 1
@@ -224,6 +228,7 @@ ddddddddd 0
 -interface_address 127.0.0.1.1225
 -received_protocol esmtp
 -body_linecount 0
+-max_received_linelength 25
 -deliver_firsttime
 XX
 1
@@ -247,6 +252,7 @@ ddddddddd 0
 -interface_address 127.0.0.1.1225
 -received_protocol esmtp
 -body_linecount 0
+-max_received_linelength 25
 -deliver_firsttime
 XX
 1
@@ -270,6 +276,7 @@ ddddddddd 0
 -interface_address 127.0.0.1.1225
 -received_protocol esmtp
 -body_linecount 0
+-max_received_linelength 25
 -deliver_firsttime
 XX
 1
index a29cad6182a89bf26b68575b71d2c3345073175c..36332a61b6f811d33557fa334f6bd41b456d07eb 100644 (file)
@@ -10,6 +10,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local
 -body_linecount 1
+-max_received_linelength 25
 -auth_id CALLER
 -auth_sender CALLER@myhost.test.ex
 -allow_unqualified_recipient
index 30fc9dc444d2253e234db5ae0a1fa3b1ae9b5250..1d364b4e9b64bc114c44c1ae5bb7a776e21c354e 100644 (file)
@@ -5,6 +5,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local
 -body_linecount 0
+-max_received_linelength 19
 -auth_id CALLER
 -auth_sender CALLER@test.ex
 -allow_unqualified_recipient
@@ -34,6 +35,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local
 -body_linecount 0
+-max_received_linelength 19
 -auth_id CALLER
 -auth_sender CALLER@test.ex
 -allow_unqualified_recipient
@@ -63,6 +65,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local
 -body_linecount 0
+-max_received_linelength 0
 -auth_id CALLER
 -auth_sender CALLER@test.ex
 -allow_unqualified_recipient
index 00a65464033a2a2414601feb5e77c61b21c6b17a..947c4e0c5660dcf99b01855b40e4274b037d21ec 100644 (file)
@@ -5,6 +5,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local
 -body_linecount 0
+-max_received_linelength 32
 -auth_id CALLER
 -auth_sender CALLER@myhost.test.ex
 -allow_unqualified_recipient
@@ -40,6 +41,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local
 -body_linecount 0
+-max_received_linelength 14
 -auth_id CALLER
 -auth_sender CALLER@myhost.test.ex
 -allow_unqualified_recipient
@@ -68,6 +70,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local
 -body_linecount 0
+-max_received_linelength 18
 -auth_id CALLER
 -auth_sender CALLER@myhost.test.ex
 -allow_unqualified_recipient
index b563d1cd412ba6d0c84b7829a5fad449822849d6..45190072f2fb0d1e7b1ae2a37fede3d495d18310 100644 (file)
@@ -5,6 +5,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local
 -body_linecount 0
+-max_received_linelength 46
 -auth_id CALLER
 -auth_sender CALLER@myhost.test.ex
 -allow_unqualified_recipient
@@ -32,6 +33,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local
 -body_linecount 0
+-max_received_linelength 46
 -auth_id CALLER
 -auth_sender CALLER@myhost.test.ex
 -allow_unqualified_recipient
index 870dc3b55b47387e574a86043f62fcae915d3b56..a977513538b19e23a5135da5ef3351674156d39d 100644 (file)
@@ -9,6 +9,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local
 -body_linecount 0
+-max_received_linelength 0
 -auth_id CALLER
 -auth_sender CALLER@test.ex
 -allow_unqualified_recipient
index 140f53b9a2187f79b03bd2d7d55881bafc740ef1..59742e66692ad878471ef73f7f054c4e5794f78a 100644 (file)
@@ -5,6 +5,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local
 -body_linecount 0
+-max_received_linelength 0
 -auth_id CALLER
 -auth_sender CALLER@myhost.test.ex
 -allow_unqualified_recipient
index bbaa49a14296260f1dd63253a639731f663aba62..e64fdef167c632a45d725025c691f5b63b74acd5 100644 (file)
@@ -5,6 +5,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local
 -body_linecount 0
+-max_received_linelength 0
 -auth_id CALLER
 -auth_sender CALLER@myhost.test.ex
 -allow_unqualified_recipient
index 00857b734f0d1f3a22596f722a6dce16c70b5c8b..7bfea116f33cf4d4766adf89ac1bf6d6d21529cb 100644 (file)
@@ -5,6 +5,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local
 -body_linecount 0
+-max_received_linelength 0
 -auth_id CALLER
 -auth_sender CALLER@myhost.test.ex
 -allow_unqualified_recipient
index b361850cf8e3b7f7cd1edd7e88248e9befa99e9c..69b1bfc001239c4cf1748b58d2274655e4f34c9b 100644 (file)
@@ -13,6 +13,7 @@ ddddddddd 0
 -aclm 0 22
 >Sender verify failed<
 -body_linecount 0
+-max_received_linelength 0
 -auth_id CALLER
 -allow_unqualified_recipient
 -allow_unqualified_sender
index 6acd7cee341b31e05fe7215546952e9bf094a4e2..ff89ff2f76ca37f74db9c2bd7b85c5e645c4d6cc 100644 (file)
@@ -11,6 +11,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local-smtp
 -body_linecount 0
+-max_received_linelength 0
 -auth_id CALLER
 -allow_unqualified_recipient
 -allow_unqualified_sender
index d5a87dabbdee25839d6ee938fddaa44341f6801b..f9cb83d19b1edf81523dfda6d2d95f000bc91261 100644 (file)
@@ -15,6 +15,7 @@ ddddddddd 0
 -ident CALLER
 -received_protocol local-smtp
 -body_linecount 2
+-max_received_linelength 6
 -auth_id CALLER
 -allow_unqualified_recipient
 -allow_unqualified_sender
index dd078c1c9a174f50810bdabd1cf6aea31c59d4bd..83111ea92dce253162246b367ace186850f78a4f 100644 (file)
@@ -8,6 +8,7 @@ ddddddddd 0
 -ident spaced user
 -received_protocol local
 -body_linecount 1
+-max_received_linelength 7
 -auth_id spaced user
 -auth_sender spaced user@myhost.test.ex
 -allow_unqualified_recipient
index 03dd58a208c627bbe7460ac6175479255c9a13bf..3e42bc19dfee4eed582cef351dcea8fc99c81180 100644 (file)
@@ -1,9 +1,10 @@
 > From: Himself <himself@there.tld>
 > Subject: The subject is not the object
-> message_body_size=33
-> message_size=369
+> message_body_size=71
+> message_size=407
 > message_id=10HmaX-0005vi-00
 > message_exim_id=10HmaX-0005vi-00
+> max_received_linelength=70
 > recipients=userx@test.x, usery@test.ex
 > 
 > from: A Person <a.person@a.domain.tld>
@@ -14,6 +15,7 @@
 > message_exim_id=10HmaY-0005vi-00
 > message_linecount=6
 > message_body_linecount=2
+> max_received_linelength=50
 > headers -----------------
 > From: A Person <a.person@a.domain.tld>
 To: First <first@test.ex>, Second <second@test.ex>
index bc9555c02281f862055baf9cf6b231ff329d0e3a..7bbd8061e836cf23066500a582a6e83df8d20b9e 100644 (file)
@@ -153,6 +153,7 @@ ddddddddd 0
 -interface_address 127.0.0.1.1225
 -received_protocol esmtpa
 -body_linecount 0
+-max_received_linelength 0
 -auth_id username
 -deliver_firsttime
 XX
@@ -178,6 +179,7 @@ ddddddddd 0
 -interface_address 127.0.0.1.1225
 -received_protocol esmtpa
 -body_linecount 0
+-max_received_linelength 0
 -auth_id username
 -deliver_firsttime
 XX
@@ -201,6 +203,7 @@ ddddddddd 0
 -interface_address 127.0.0.1.1225
 -received_protocol esmtpa
 -body_linecount 0
+-max_received_linelength 0
 -auth_id username
 -deliver_firsttime
 XX
@@ -224,6 +227,7 @@ ddddddddd 0
 -interface_address 127.0.0.1.1225
 -received_protocol esmtpa
 -body_linecount 0
+-max_received_linelength 0
 -auth_id username@auth.id.domain
 -deliver_firsttime
 XX
@@ -247,6 +251,7 @@ ddddddddd 0
 -interface_address 127.0.0.1.1225
 -received_protocol esmtpa
 -body_linecount 0
+-max_received_linelength 15
 -auth_id username@auth.id.domain
 -deliver_firsttime
 XX