INN commit: trunk/innd (art.c)

INN Commit rra at isc.org
Sat Jul 17 10:34:39 UTC 2010


    Date: Saturday, July 17, 2010 @ 03:34:39
  Author: iulius
Revision: 9086

This patch causes both CRwithoutLF (\r) and LFwithoutCR (\n) to be
considered the same as CRLF (\r\n) for purposes of checking allowable
header line length.

It appears that some people like to grace their articles with Face: or
X-Face: headers of typically 4-6k binary data.  While usually put into
nice continuation lines of around 80 characters, a few clients fail to
create proper line breaks for this header, inserting only a single \r or
\n instead.  The nnrpd in INN 2.3 doesn't reject or correct these mistakes
for non-system headers, and offending articles are still "in the wild".

innd currently counts, logs and ignores such imperfect line breaks.
Alas, when checking for the maximum allowable 'physical' line length,
single \r or \n are not recognized, thus making the whole 'virtual'
(continued) header appear as a single line, easily exceeding
MAXARTLINELENGTH and thus causing the article to be rejected.

Thanks to Florian Schlichting for the patch.

Modified:
  trunk/innd/art.c

-------+
 art.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Modified: art.c
===================================================================
--- art.c	2010-07-17 08:59:44 UTC (rev 9085)
+++ art.c	2010-07-17 10:34:39 UTC (rev 9086)
@@ -806,8 +806,13 @@
     for (i = cp->Next; i < bp->used; i++) {
         if (bp->data[i] == '\0')
             ARTerror(cp, "Nul character in header");
-        if (bp->data[i] == '\n')
+        if (bp->data[i] == '\n') {
             data->LFwithoutCR++;
+            /* Behave as though we really saw a new line (otherwise,
+             * the length of the header line may be exceeded in
+             * non-compliant messages). */
+            data->LastCRLF = i;
+        }
         if (bp->data[i] != '\r')
             continue;
 
@@ -875,6 +880,10 @@
             data->LastCRLF = i - 1;
         } else {
             data->CRwithoutLF++;
+            /* Behave as though we really saw a new line (otherwise,
+             * the length of the header line may be exceeded in
+             * non-compliant messages). */
+            data->LastCRLF = i;
         }
     }
     cp->Next = i;
@@ -2563,7 +2572,7 @@
                data->LFwithoutCR);
     else
       snprintf(cp->Error, sizeof(cp->Error),
-               "Article accepted but includes CR without LF(%d) and LF withtout CR(%d)",
+               "Article accepted but includes CR without LF(%d) and LF without CR(%d)",
                data->CRwithoutLF, data->LFwithoutCR);
     /* We have another ARTlog() for the same article just after. */
     ARTlog(data, ART_STRSTR, cp->Error);




More information about the inn-committers mailing list