diff -u -r1.52 commands.c --- commands.c 2001/06/29 21:42:23 1.52 +++ commands.c 2001/12/12 04:55:36 @@ -255,6 +255,8 @@ } else { if (caseEQ(av[1], "simple")) { + ac--; + ac += reArgify(av[ac],&av[ac],2); // two more should make four if (ac != 4) { Reply("%d AUTHINFO SIMPLE \r\n", NNTP_BAD_COMMAND_VAL); return; diff -u -r1.52 misc.c --- misc.c 2001/07/11 07:40:46 1.52 +++ misc.c 2001/12/12 04:55:36 @@ -33,6 +33,7 @@ #endif + /* ** Parse a string into a NULL-terminated array of words; return number ** of words. If argvp isn't NULL, it and what it points to will be @@ -43,7 +44,24 @@ char *line; char ***argvp; { - register char **argv; + return nArgify(line,argvp,-1); +} + + +/* +** Parse a string into a NULL-terminated array of at most n words; +** return number of words. If there are more than n words, stop +** processing at the beginning of the (n+1)th word, store everything +** from the beginning of word n+1 in argv[n] and return n+1. If n is +** negative, parses all words. If argvp isn't NULL, it and what it +** points to will be DISPOSE'd. +*/ +int +nArgify(line, argvp, n) + char *line; + char ***argvp; + int n; +{ register char *p; register int i; @@ -59,10 +77,46 @@ p = NEW(char, i + 1); (void)strcpy(p, line); - /* Allocate worst-case amount of space. */ - for (*argvp = argv = NEW(char*, i + 2); *p; ) { - /* Mark start of this word, find its end. */ - for (*argv++ = p; *p && !ISWHITE(*p); ) + *argvp = NEW(char*, i + 2); + + return reArgify(p, *argvp, n); +} + + +/* +** Destructively parse a string into a NULL-terminated array of at most +** n words; return number of words. Behavior on negative n and strings +** of more than n words matches that of nArgify (see above). Caller +** must supply an array of sufficient size (such as created by +** nArgify). +** +** Note that the sequence +** ac = nArgify(line, &argv, n1); +** ac--; +** ac += reArgify(argv[ac], &argv[ac], n2); +** is equivalent to +** ac = nArgify(line, &argv, n1 + n2); +*/ +int +reArgify(p, argv, n) + register char *p; + char **argv; + int n; +{ + char **save=argv; + + + /* Should never happen unless caller modifies argv between calls */ + while (ISWHITE(*p)) + p++; + + for ( ; *p; ) { + if (n == 0) { + *argv++ = p; + break; + } + /* Decrement limit, mark start of this word, find its end. */ + for (n--, *argv++ = p; *p && !ISWHITE(*p); ) p++; if (*p == '\0') break; @@ -72,7 +126,7 @@ p++; } *argv = NULL; - return argv - *argvp; + return argv - save; } diff -u -r1.120 nnrpd.c --- nnrpd.c 2001/09/25 07:32:15 1.120 +++ nnrpd.c 2001/12/12 04:55:36 @@ -123,7 +123,7 @@ static char CMDfetchhelp[] = "[MessageID|Number]"; static CMDENT CMDtable[] = { - { "authinfo", CMDauthinfo, FALSE, 3, CMDany, + { "authinfo", CMDauthinfo, FALSE, 2, CMDany, "user Name|pass Password|generic " }, #ifdef HAVE_SSL { "starttls", CMDstarttls, FALSE, 1, 1, @@ -1169,7 +1169,7 @@ continue; if (Tracing) syslog(L_TRACE, "%s < %s", ClientHost, PushedBack); - ac = Argify(PushedBack, &av); + ac = nArgify(PushedBack, &av, 1); r = RTok; } else @@ -1195,7 +1195,7 @@ syslog(L_TRACE, "%s < %s", ClientHost, buff); if (buff[0] == '\0') continue; - ac = Argify(buff, &av); + ac = nArgify(buff, &av, 1); break; case RTeof: /* Handled below. */ @@ -1220,6 +1220,10 @@ Reply("%d What?\r\n", NNTP_BAD_COMMAND_VAL); continue; } + + ac--; + ac += reArgify(av[ac], &av[ac], + (cp->Maxac != CMDany ? cp->Maxac : cp->Minac - ac)); /* Check usage. */ if ((cp->Minac != CMDany && ac < cp->Minac) diff -u -r1.52 nnrpd.h --- nnrpd.h 2001/07/29 14:36:36 1.52 +++ nnrpd.h 2001/12/12 04:55:36 @@ -188,6 +188,8 @@ extern bool ARTreadschema(); extern char *Glom(); extern int Argify(); +extern int nArgify(); +extern int reArgify(); extern void ExitWithStats(int x, bool readconf); extern bool GetGroupList(); extern char *GetHeader(char *header, bool IsLines);