Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/3/84; site enmasse.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!teddy!panda!enmasse!guy
From: guy@enmasse.UUCP (Guy K. Hillyer)
Newsgroups: net.news.b
Subject: bug in inews (2.10.2)
Message-ID: <224@enmasse.UUCP>
Date: Wed, 12-Dec-84 19:21:33 EST
Article-I.D.: enmasse.224
Posted: Wed Dec 12 19:21:33 1984
Date-Received: Fri, 14-Dec-84 06:25:06 EST
Distribution: net
Organization: Enmasse Computer Corp., Acton, Mass.
Lines: 41

My copy of inews always inserted a byte with the value 0xff
(value of EOF in stdio) into messages with 0 lines in the text
part (a characteristic of many control messages).  When such messages
show up in the input to bnproc, it gets confused because it thinks
it has seen an EOF in the middle of the file.  The result is that
subsequent messages in the batch file get thrown away.

Here is the offending code, from the function 'insert' in inews.c:

	/* Write article to temp file. */
	tfp = xfopen(mktemp(ARTICLE), "w");
	if ( (c=getc(infp)) == ' ' || c == '\t' ) {
		header.intnumlines++;
		sprintf(header.numlines,"%d",header.intnumlines);
	}
	lhwrite(&header, tfp);
	/* Kludge to get around article truncation problem */
	if (c == ' ' || c == '\t' )
		putc('\n', tfp);
	putc(c,tfp);
	while (fgets(bfr, BUFLEN, infp) != NULL)
		fputs(bfr, tfp);

There is no check for the call to getc returning EOF (which
happens if the message has only control headers and no
text lines), so EOF gets written into the message file.
I fixed it here by changing this line
	
	putc(c,tfp);

to 
	if (c != EOF) putc(c,tfp);

This is a kludge on top of a kludge, but I wanted to change
the code as little as possible.  What I'm wondering is how 
widespread the problem is.  Was this kludge part of the original
release, or did it surreptitiously sneak into the code en route
to here?

			-- Guy Hillyer
			{decvax,linus,harvard!wjh12}!genrad!enmasse!guy