INN commit: branches/2.5/innd (nc.c)

INN Commit rra at isc.org
Sun Nov 15 09:21:52 UTC 2009


    Date: Sunday, November 15, 2009 @ 01:21:52
  Author: iulius
Revision: 8767

* Add support for whitespaces in username/password for AUTHINFO
USER/PASS commands.

* Properly retain the whole (possibly syntactically wrong)
message-ID of CHECK/TAKETHIS commands.

Modified:
  branches/2.5/innd/nc.c

------+
 nc.c |   44 ++++++++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 16 deletions(-)

Modified: nc.c
===================================================================
--- nc.c	2009-11-15 09:21:40 UTC (rev 8766)
+++ nc.c	2009-11-15 09:21:52 UTC (rev 8767)
@@ -25,6 +25,7 @@
     bool                     Needauth;
     int                      Minac;
     int                      Maxac;
+    bool                     Stripspaces;
     const char *             Help;
 } NCDISPATCH;
 
@@ -54,33 +55,33 @@
 
 /* Set up the dispatch table for all of the commands. */
 #define NC_any -1
-#define COMMAND(name, func, auth, min, max, help) { name, func, auth, min, max, help }
-#define COMMAND_READER(name) { name, NC_reader, false, 1, NC_any, NULL }
-#define COMMAND_UNIMP(name)  { name, NC_unimp,  false, 1, NC_any, NULL }
+#define COMMAND(name, func, auth, min, max, strip, help) { name, func, auth, min, max, strip, help }
+#define COMMAND_READER(name) { name, NC_reader, false, 1, NC_any, true, NULL }
+#define COMMAND_UNIMP(name)  { name, NC_unimp,  false, 1, NC_any, true, NULL }
 static NCDISPATCH NCcommands[] = {
-    COMMAND("AUTHINFO",      NCauthinfo,      false, 3,  3,
+    COMMAND("AUTHINFO",      NCauthinfo,      false, 3,  3, false,
             "USER name|PASS password"),
-    COMMAND("CAPABILITIES",  NCcapabilities,  false, 1,  2,
+    COMMAND("CAPABILITIES",  NCcapabilities,  false, 1,  2, true,
             "[keyword]"),
-    COMMAND("CHECK",         NCcheck,         true,  2,  2,
+    COMMAND("CHECK",         NCcheck,         true,  2,  2, false,
             "message-ID"),
-    COMMAND("HEAD",          NChead,          true,  1,  2,
+    COMMAND("HEAD",          NChead,          true,  1,  2, true,
             "message-ID"),
-    COMMAND("HELP",          NChelp,          false, 1,  1,
+    COMMAND("HELP",          NChelp,          false, 1,  1, true,
             NULL),
-    COMMAND("IHAVE",         NCihave,         true,  2,  2,
+    COMMAND("IHAVE",         NCihave,         true,  2,  2, true,
             "message-ID"),
-    COMMAND("LIST",          NClist,          true,  1,  3,
+    COMMAND("LIST",          NClist,          true,  1,  3, true,
             "[ACTIVE|ACTIVE.TIMES|NEWSGROUPS [wildmat]]"),
-    COMMAND("MODE",          NCmode,          false, 2,  2,
+    COMMAND("MODE",          NCmode,          false, 2,  2, true,
             "READER"),
-    COMMAND("QUIT",          NCquit,          false, 1,  1,
+    COMMAND("QUIT",          NCquit,          false, 1,  1, true,
             NULL),
-    COMMAND("STAT",          NCstat,          true,  1,  2,
+    COMMAND("STAT",          NCstat,          true,  1,  2, true,
             "message-ID"),
-    COMMAND("TAKETHIS",      NCtakethis,      true,  2,  2,
+    COMMAND("TAKETHIS",      NCtakethis,      true,  2,  2, false,
             "message-ID"),
-    COMMAND("XBATCH",        NCxbatch,        true,  2,  2,
+    COMMAND("XBATCH",        NCxbatch,        true,  2,  2, true,
             "size"),
 
     /* Unimplemented reader commands which may become available after a MODE
@@ -1113,7 +1114,7 @@
       /* Guarantee null-termination. */
       p[-2] = '\0';
       p = q;
-      ac = Argify(p, &av);
+      ac = nArgify(p, &av, 1);
 
       /* Ignore empty lines. */
       if (ac == 0) {
@@ -1213,6 +1214,17 @@
         break;
       }
 
+      /* Go on parsing the command.
+       * For instance:
+       * - "CHECK     <bad mid>  " will give the message-ID "<bad mid>  "
+       *   with only leading whitespaces stripped.
+       * - "AUTHINFO USER  test " will give the username " test " with
+       *   no whitespaces stripped. */
+      ac--;
+      ac += reArgify(av[ac], &av[ac],
+                     dp->Stripspaces ? -1 : dp->Minac - ac - 1,
+                     dp->Stripspaces);
+
       /* Check whether all arguments do not exceed their allowed size. */
       if (ac > 1) {
           validcommandtoolong = false;




More information about the inn-committers mailing list