stdio on SYSV vrs BSD

Chris Torek chris at mimsy.umd.edu
Sat May 5 15:07:10 AEST 1990


In article <558 at venice.SEDD.TRW.COM> waldorf at venice.SEDD.TRW.COM
(Jerry Waldorf) writes:
>In the file /usr/include/stdio.h on a BSD box, there is a defined:
>#define _IOSTRG	0100
>What exactly is this used for?

Almost nothing.  It is set in exactly two places (sprintf and sscanf) and
tested in one (_filbuf).  In particular, it is not tested in _flsbuf,
so that

	char dst[32800], src[32768];
	int i;
	for (i=0; i<32767; i++) src[i] = 'x';
	src[32767] = 0;
	sprintf(dst, "too much: %s", src);

calls write() on a random file descriptor.  All _IOSTRG really does
is keep _filbuf() from reading from a random file descriptor.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list