INN commit: trunk (6 files)

INN Commit rra at isc.org
Fri Oct 29 18:24:01 UTC 2010


    Date: Friday, October 29, 2010 @ 11:24:01
  Author: iulius
Revision: 9139

Check MAXARTLINELENGTH in nnrpd, not innd.

This patch means reverting the previous "CRwithoutLF" patch [9086] and
also ripping out all length checking and both unsigned long length as well
as data->LastCRLF.

Thanks to Florian Schlichting for the patch.

Modified:
  trunk/doc/pod/news.pod
  trunk/innd/art.c
  trunk/innd/innd.h
  trunk/innd/nc.c
  trunk/nnrpd/post.c
  trunk/tests/innd/artparse-t.c

-------------------------+
 doc/pod/news.pod        |   10 ++++++----
 innd/art.c              |   19 +------------------
 innd/innd.h             |    3 ---
 innd/nc.c               |    1 -
 nnrpd/post.c            |   23 ++++++++++++++++++-----
 tests/innd/artparse-t.c |    6 ++----
 6 files changed, 27 insertions(+), 35 deletions(-)

Modified: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod	2010-10-29 18:09:50 UTC (rev 9138)
+++ doc/pod/news.pod	2010-10-29 18:24:01 UTC (rev 9139)
@@ -129,7 +129,7 @@
 When a header field appeared more than once in an article, it was missing
 from the overview data.  OVER/XOVER, as well as HDR/XHDR/XPAT using the
 overview, were therefore returning an empty field.  The content of the
-first occurrence is now returned, in accordance with RFC 3977.
+first occurrence is now returned, in accordance with S<RFC 3977>.
 
 Perl and Python filters for B<innd> now also properly initialize their
 headers variables with the first occurrence of header fields.  (It is
@@ -149,9 +149,11 @@
 
 =item *
 
-A single header field line is limited to 998 bytes, per S<RFC 5536>.
-B<innd> was previously accepting, and also generating Xref: header field
-lines, up to 1022 bytes.
+A single header field line is limited to 998 bytes, per S<RFC 5536>.  B<innd>
+was previously accepting, and also generating Xref: header field lines,
+up to 1022 bytes.  Now, B<nnrpd> (acting as an injecting agent) rejects
+articles which contain header field lines whose length exceeds 998 bytes.
+And B<innd> (acting as a relaying or serving agent) no longer checks that.
 
 =item *
 

Modified: innd/art.c
===================================================================
--- innd/art.c	2010-10-29 18:09:50 UTC (rev 9138)
+++ innd/art.c	2010-10-29 18:24:01 UTC (rev 9139)
@@ -730,7 +730,7 @@
   }
   data->Lines = data->HeaderLines = data->CRwithoutLF = data->LFwithoutCR = 0;
   data->DotStuffedLines = 0;
-  data->CurHeader = data->LastCRLF = data->Body = cp->Start;
+  data->CurHeader = data->Body = cp->Start;
   data->BytesHeader = NULL;
   data->Feedsite = "?";
   data->FeedsiteLength = strlen(data->Feedsite);
@@ -807,17 +807,12 @@
     struct buffer *bp = &cp->In;
     ARTDATA *data = &cp->Data;
     size_t i;
-    unsigned long length;
 
     for (i = cp->Next; i < bp->used; i++) {
         if (bp->data[i] == '\0')
             ARTerror(cp, "Nul character in header");
         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;
@@ -853,13 +848,6 @@
             cp->Next = i + 5;
             return;
         } else if (bp->data[i + 1] == '\n') {
-            length = i - data->LastCRLF - 1;
-            if (data->LastCRLF == cp->Start)
-                length++;
-            /* length includes final CRLF. */
-            if (length > MAXARTLINELENGTH)
-                ARTerror(cp, "Header line too long (%lu bytes)", length);
-
             /* Be a little tricky here.  Normally, the headers end at the
                first occurrence of \r\n\r\n, so since we've seen \r\n, we want
                to advance i and then look to see if we have another one.  The
@@ -883,13 +871,8 @@
                 ARTparsebody(cp);
 		return;
             }
-            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;

Modified: innd/innd.h
===================================================================
--- innd/innd.h	2010-10-29 18:09:50 UTC (rev 9138)
+++ innd/innd.h	2010-10-29 18:24:01 UTC (rev 9139)
@@ -262,9 +262,6 @@
   size_t	  CurHeader;		/* where current header starts.
 					   this is used for folded header
 					   it indicates offset from bp->Data */
-  size_t	  LastCRLF;		/* where last CRLF exists.
-					   indicates where last LF exists
-					   it indicates offset from bp->Data */
   HDRCONTENT	  HdrContent[MAX_ARTHEADER];
 					/* includes system headers info */
   bool            AddAlias;             /* Whether Pathalias should be added

Modified: innd/nc.c
===================================================================
--- innd/nc.c	2010-10-29 18:09:50 UTC (rev 9138)
+++ innd/nc.c	2010-10-29 18:24:01 UTC (rev 9139)
@@ -1577,7 +1577,6 @@
 	cp->State == CSeatarticle) {
 	/* adjust offset only in CSgetheader, CSgetbody or CSeatarticle */
 	data->CurHeader -= cp->Start;
-	data->LastCRLF -= cp->Start;
 	data->Body -= cp->Start;
 	if (data->BytesHeader != NULL)
 	  data->BytesHeader -= cp->Start;

Modified: nnrpd/post.c
===================================================================
--- nnrpd/post.c	2010-10-29 18:09:50 UTC (rev 9138)
+++ nnrpd/post.c	2010-10-29 18:24:01 UTC (rev 9139)
@@ -168,12 +168,26 @@
 static char *
 NextHeader(char *p)
 {
-    for ( ; (p = strchr(p, '\n')) != NULL; p++) {
-	if (ISWHITE(p[1]))
-	    continue;
+    char *q;
+    for (q = p; (p = strchr(p, '\n')) != NULL; p++) {
+        /* Note that '\r\n' has temporarily been internally replaced by '\n'.
+         * Therefore, the count takes it into account (+1, besides the
+         * length (p-q+1) of the string). */
+        if (p - q + 2 > MAXARTLINELENGTH) {
+            strlcpy(Error, "Header line too long",
+                    sizeof(Error));
+            return NULL;
+        }
+        /* Check if there is a continuation line for the header. */
+        if (ISWHITE(p[1])) {
+            q = p + 1;
+            continue;
+        }
 	*p = '\0';
 	return p + 1;
     }
+    strlcpy(Error, "Article has no body -- just headers",
+            sizeof(Error));
     return NULL;
 }
 
@@ -230,8 +244,7 @@
 
 	/* Get start of next header; if it's a blank line, we hit the end. */
 	if ((p = NextHeader(p)) == NULL) {
-	    strlcpy(Error, "Article has no body -- just headers",
-                    sizeof(Error));
+            /* Error set in NextHeader(). */
 	    return NULL;
 	}
 	if (*p == '\n')

Modified: tests/innd/artparse-t.c
===================================================================
--- tests/innd/artparse-t.c	2010-10-29 18:09:50 UTC (rev 9138)
+++ tests/innd/artparse-t.c	2010-10-29 18:24:01 UTC (rev 9139)
@@ -36,10 +36,8 @@
       "437 Space before colon in \"Test\" header" },
     { "../data/articles/bad-hdr-trunc",
       "437 No colon-space in \"Test:\" header" },
-    { "../data/articles/bad-long-cont",
-      "437 Header line too long (1001 bytes)" },
-    { "../data/articles/bad-long-hdr",
-      "437 Header line too long (1001 bytes)" },
+    { "../data/articles/bad-long-cont", "" }, /* Not an error for a relaying agent. */
+    { "../data/articles/bad-long-hdr", "" }, /* Not an error for a relaying agent. */
     { "../data/articles/bad-no-body",
       "437 No body" },
     { "../data/articles/bad-no-header",




More information about the inn-committers mailing list