[net.news.b] argparse

geoff@desint.UUCP (Geoff Kuenning) (09/22/84)

I was just experimenting with 'sendme' to see if I could use it to extract
a certain article from a neighboring system, and as a result located a
bug in control.c.  The argparse() routine does not count arguments
correctly unless they are followed by whitespace.  Since sendme() is the
only routine that actually uses the argument count, you will never have
this problem until some remote site decides to send you a sendme();  then
you will reject the control message because you are trying to use the
article ID as a site name.

The fix is easy:  change one line and move one line in control.c.  The
contextual diffs follow.

*** ../distsrc/control.c
--- control.c

*** 78,82
  	if (str == 0)
  		xerror("Control message %s has no title", header.ident);
! 	cargc = 0;
  	cargv = cavpbuf;
  	cargv[0] = cavbuf;
--- 78,82
  	if (str == 0)
  		xerror("Control message %s has no title", header.ident);
! 	cargc = (*str != 0);
  	cargv = cavpbuf;
  	cargv[0] = cavbuf;

*** 85,90
  		if (*str <= ' ') {
  			*nextfree++ = 0;
- 			cargc++;
  			cargv[cargc] = nextfree;
  			/* skip over white space */
  			while (*str > 0 && *str <= ' ')
--- 85,90
  		if (*str <= ' ') {
  			*nextfree++ = 0;
  			cargv[cargc] = nextfree;
+ 			cargc++;
  			/* skip over white space */
  			while (*str > 0 && *str <= ' ')
-- 

	Geoff Kuenning
	...!ihnp4!wlbr!desint!geoff