gets(3) nonsense

Maarten Litmaath maart at cs.vu.nl
Tue Nov 15 07:50:28 AEST 1988


In article <434 at auspex.UUCP> guy at auspex.UUCP (Guy Harris) writes:
\>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? 

Hey people! I just found out somebody put a nasty little program in /bin!
It's called `rm'. If you type `rm *', all your files will disappear!

\Or somebody put it in there so that you could avoid the nasty run-time
\overhead of checking string bounds?

Of course! If you want security, use fgets()!
-- 
fcntl(fd, F_SETFL, FNDELAY):          |Maarten Litmaath @ VU Amsterdam:
      let's go weepin' in the corner! |maart at cs.vu.nl, mcvax!botter!maart



More information about the Comp.lang.c mailing list