From owner-freebsd-hackers Wed Oct 29 05:41:07 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id FAA16181 for hackers-outgoing; Wed, 29 Oct 1997 05:41:07 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from eddie.mit.edu (EDDIE.MIT.EDU [18.62.0.6]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id FAA16166 for ; Wed, 29 Oct 1997 05:41:02 -0800 (PST) (envelope-from gdk@ccomp.inode.COM) Received: from ccomp.inode.com by eddie.mit.edu id aa03431; 29 Oct 97 8:34 EST Received: (from gdk@localhost) by ccomp.inode.com (8.6.9/1.5) id IAA03379; Wed, 29 Oct 1997 08:24:16 -0500 From: Gary Kendall Message-Id: <199710291324.IAA03379@ccomp.inode.com> Subject: Re: gets To: Jacques Hugo Date: Wed, 29 Oct 1997 08:24:15 -0500 (EST) Cc: hackers@freebsd.ORG In-Reply-To: <3456E072.794BDF32@wired.ctech.ac.za> from Jacques Hugo at "Oct 29, 97 09:06:26 am" X-Mailer: ELM [version 2.4ME+ PL17 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@freebsd.ORG X-Loop: FreeBSD.org Precedence: bulk It wasn't too long ago that Jacques Hugo said: > Hi there ... > > Whenever I use gets(3) to read from > stdin, I get > > warning: this program uses gets(), which is unsafe. > > The program works ok, no problem there. But I > don't like that error. Is there someting else > I can use, or maybe a work-around to read > from stdin. > > Thanks > > -Jacuqes > > ------------------------------------------------------ > The box said "Requires Windows 3.1 or better" > ... so I got BSD > > System Administrator | Jacques Hugo > UNIX Systems | jacques@wired.ctech.ac.za > Cape Technikon | +27-21-4603584 > ------------------------------------------------------ > You should use fgets() so you can specify the buffer size and prevent data overruns which have the potential of "writing new code" into your program. Regards, Gary Kendall %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % The difficult is done immediately, the impossible takes a little longer. % %----------------------------------------------------------------------------% % gdk@ccomp.inode.com or gkendall@eddie.mit.edu % %----------------------------------------------------------------------------% % Creative Computing * 96 Forest Street * Danvers, MA 01923 * 978-777-3784 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%