INN commit: trunk/nnrpd (post.c)

INN Commit rra at isc.org
Thu Dec 31 22:45:25 UTC 2020


    Date: Thursday, December 31, 2020 @ 14:45:22
  Author: eagle
Revision: 10476

Add detail for rejected header

When nnrpd rejects a posting because of an invalid header that
isn't part of the header table, include the name of the header
as an aid in debugging, or the full header if no colon could be
found or if the line starts with a colon.

Reported by Adam Sj{U+00F8}gren and Lars Ingebrigtsen.

Modified:
  trunk/nnrpd/post.c

--------+
 post.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Modified: post.c
===================================================================
--- post.c	2020-12-25 22:00:11 UTC (rev 10475)
+++ post.c	2020-12-31 22:45:22 UTC (rev 10476)
@@ -348,6 +348,7 @@
     static char		*newpath = NULL;
     HEADER		*hp;
     char		*p;
+    char		*bad_header;
     char		*fqdn = NULL;
     time_t		t, now;
     const char          *error;
@@ -645,9 +646,16 @@
     /* Check that all other header fields are valid. */
     for (i = 0; i < OtherCount; i++) {
         if (!IsValidHeaderField(OtherHeaders[i])) {
+            p = strchr(OtherHeaders[i], ':');
+            if (p == NULL || p == OtherHeaders[i])
+                bad_header = xstrdup(OtherHeaders[i]);
+            else
+                bad_header = xstrndup(OtherHeaders[i], p - OtherHeaders[i]);
             snprintf(Error, sizeof(Error),
-                     "Invalid syntax encountered in headers (unexpected "
-                     "byte, no colon-space, or empty content line)");
+                     "Invalid syntax encountered in header (unexpected "
+                     "byte, no colon-space, or empty content line): %s",
+                     bad_header);
+            free(bad_header);
             return Error;
         }
     }



More information about the inn-committers mailing list