[news.software.b] news 2.11 unbatch bug

wayne@batcomputer.tn.cornell.edu (wayne smith) (11/08/87)

There is still a bug (not fixed in patch #12) that causes machines that
cannot dereference zero to lose a large percentage of incoming batched
articles.  When a batched article is "small" and an inews is forked off
to read it, the two processes use a pipe rather than a temporary file to
transfer the article.  At the end of the routine, the temporary file is
closed (even if it was never opened), and the filename string (which was
initialized to zero) is dereferenced, causing a bus error.  The rest of
the batch is lost, an no notification is given.  Here is a context diff
of a two line fix for this insidious bug:

*** ifuncs.c	Tue Oct 20 22:00:03 1987
--- ifuncs.c.sav	Sat Oct 10 12:16:50 1987
***************
*** 1079,1085
  #define CPBFSZ 8192
  			char buf[CPBFSZ];
  
! 			tfilename = "\0";
  			cp = malloc((unsigned)BUFSIZ);
  			if (cp != NULL)
  				setbuf(infp, cp);

--- 1079,1085 -----
  #define CPBFSZ 8192
  			char buf[CPBFSZ];
  
! 			tfilename = 0;
  			cp = malloc((unsigned)BUFSIZ);
  			if (cp != NULL)
  				setbuf(infp, cp);
***************
*** 1105,1111
  					if (fd < 0) {
  						if (rc == asize)
  							break;	/* fits in buffer */
! 						if (! *tfilename)
  							tfilename = mktemp("/tmp/unbnewsXXXXXX");
  						if ((fd = creat(tfilename, 0666)) < 0) {
  							fprintf(stderr, "rnews: creat of \"%s\" failed",

--- 1105,1111 -----
  					if (fd < 0) {
  						if (rc == asize)
  							break;	/* fits in buffer */
! 						if (!tfilename)
  							tfilename = mktemp("/tmp/unbnewsXXXXXX");
  						if ((fd = creat(tfilename, 0666)) < 0) {
  							fprintf(stderr, "rnews: creat of \"%s\" failed",


I'm sorry I was not able to post this earlier.  UUCP on our feed (dartvax)
won't let us use rnews (permission denied to "user").  I had to mail this
to Cornell, and post from there.

Wayne A. Smith
Creare Inc.			arpa: was%creare%dartmouth.edu@relay.cs.net
Etna Road			uucp: dartvax!creare
Hanover, NH 03755		phone: (603) 643-3800