retiring gets(3)

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Nov 18 12:43:30 AEST 1988


In article <1988Nov16.184238.16375 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>In article <8902 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>>... In fact they're wrong.  I routinely use gets() in
>>an utterly safe manner...
>Well, "utterly safe" if you're always very careful that part A of your
>program preserves the length limits that part B is relying on.  Personally
>I prefer slightly more robust programming, especially when there's no
>significant difference in convenience or efficiency.

Why work harder when gets() does exactly what one needs?

Another safe use is for small "one-shot" test programs etc. that are
to be used only by persons and procedures that will not exceed the
limits.  I've written quite a few of these over the years and they
have never had their buffers overrun, because nobody who is in a
position to do so (me, usually) has the least interest in doing so.



More information about the Comp.lang.c mailing list