gets(3) nonsense

Guy Harris guy at auspex.UUCP
Sat Nov 12 03:47:45 AEST 1988


>And now the real point: let's stop complaining about the gets(3) semantics of
>not checking buffer boundaries; this is precisely what was intended.

"Intended" in what sense?  Somebody put it in there so that people would
deliberately write programs using it, and thus would write programs that
could be made to fail by sending them lines longer than they expect? 
Or somebody put it in there so that you could avoid the nasty run-time
overhead of checking string bounds?

The former is not a good reason for doing something, so the complaints
are justified; the latter isn't all that good either, since 1) I suspect
the cost of checking the string bounds is pretty low and 2) most of the
applications I know of that read input have no control over the form of
the input, and thus could be made to exhibit buggy behavior, if they
used "gets()", just by handing them a line longer than they expect. 



More information about the Comp.lang.c mailing list