Return to BSD News archive
Xref: sserve comp.os.386bsd.questions:11859 comp.os.386bsd.development:2348 comp.os.386bsd.misc:2877 Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!sgiblab!nbn!hilbert.dnai.com!agate!priam.CS.Berkeley.EDU!edward From: edward@priam.CS.Berkeley.EDU (Edward Wang) Newsgroups: comp.os.386bsd.questions,comp.os.386bsd.development,comp.os.386bsd.misc Subject: Re: Why does FreeBSD 1.1.5 say gets() is unsafe? Date: 26 Jul 1994 21:34:56 GMT Organization: University of California, Berkeley Lines: 20 Message-ID: <313vi0$fko@agate.berkeley.edu> References: <ASAMI.94Jul21184711@forgery.cs.berkeley.edu> <31181v$ibk@agate.berkeley.edu> <ASAMI.94Jul25151654@forgery.cs.berkeley.edu> <CtJoDs.Iwz@cogsci.ed.ac.uk> NNTP-Posting-Host: priam.cs.berkeley.edu Cc: In article <CtJoDs.Iwz@cogsci.ed.ac.uk>, Richard Tobin <richard@cogsci.ed.ac.uk> wrote: >In article <ASAMI.94Jul25151654@forgery.cs.berkeley.edu> asami@cs.berkeley.edu (Satoshi ASAMI) writes: >>Hmm, so how can you write a program that uses gets() and is safe? > >By only using it to read data that you know is of the right length (eg >because you've written it, or because it's on punched cards). Thank you. Also, there no guarantee a program will work with long input lines just because it uses fgets(). It still has to worry about lines too long to fit in the buffer, which plenty of programs don't. I use getc() when I want to be perfectly "safe." I think I caused all this by using a different definition of unsafe. Since I don't want to get into arguments on semantics with people I don't know, I'll just apologize. I'm sorry I brought it up. Wrap it up now?