[net.bugs] Another news 2.10.1 bug

piet@mcvax.UUCP (Piet Beertema) (01/13/84)

There's another "forget-to-close" bug in ifuncs.c:

At the start of broadcast() there is an `xfopen("ARTICLE", "r")'
almost immediately followed by a fclose(fp).
Within the next while loop transmit() is called with as one of its
arguments (again) `xfopen("ARTICLE", "r"))'.
Now transmit() can return in several ways without closing the file,
which leaves you with too many open file descriptors when broadcasting
too many systems.
To fix it:
- move the fclose(fp) to after the while loop;
- replace the transmit() call by:
	fseek(fp, 0L, 0);
	transmit(&srec, fp, 1);
- remove the fclose(ifp) from transmit().
-- 
	Piet Beertema
	CWI (Center for Math. & Comp. Science), Amsterdam
	...{decvax,philabs}!mcvax!piet

ado@elsie.UUCP (02/03/84)

A recent posting read:
	There's another "forget-to-close" bug in ifuncs.c: At the start of
	broadcast() there is an `xfopen("ARTICLE", "r")' almost immediately
	followed by a fclose(fp).  Within the next while loop transmit() is
	called with as one of its arguments (again) `xfopen("ARTICLE", "r"))'.
	Now transmit() can return in several ways without closing the file,
	which leaves you with too many open file descriptors when broadcasting
	too many systems.  To fix it:
	- move the fclose(fp) to after the while loop;
	- replace the transmit() call by:
		fseek(fp, 0L, 0);
		transmit(&srec, fp, 1);
	- remove the fclose(ifp) from transmit().
Note, however, that there are calls to "transmit" in places other than
"broadcast", and the calls in these other places depend on "transmit" to
close the file.  So, perhaps the "make it work as designed" fix is to:
	- ensure that transmit always calls fclose on ifp (if ifp is other
	  than NULL) before returning.
-- 
UUCP:	decvax!harpo!seismo!rlgvax!cvl!elsie!ado
DDD:	(301) 496-5688