Path: utzoo!attcan!uunet!husc6!mailrus!ncar!tank!nic.MR.NET!shamash!halcdc!randy From: randy@halcdc.UUCP (randy orrison) Newsgroups: comp.lang.c Subject: Re: v05i053: A "safe" replacement for gets() Summary: Oops... Message-ID: <117@halcdc.UUCP> Date: 16 Nov 88 17:26:27 GMT References: <674@quintus.UUCP> Reply-To: randy@halcdc.UUCP (randy orrison) Organization: Control Data in the Hills of Arden, Minnesota Lines: 26 In article <674@quintus.UUCP> Brandon Allbury writes: |[Aaaaagh. I always suspected gets() was a potential bomb. How about | |#define gets(s) fgets(s, sizeof s, stdin) | |as a quick fix? ++bsa] { char *s; s = malloc (80); gets (s); } Two problems: the space after gets would kill it if it's a macro, and sizeof (s) != 80 (on most machines). Which means that you'd have to examine your code to make sure the macro would work, and fix it if not, so why not just fix it to use fgets? -randy -- Randy Orrison - Control Data in the Hills of Arden randy@halcdc.uucp aka randy@{ux.acss.umn.edu, umnacvx.bitnet, cctb.mn.org, umn-cs.uucp} ZQOTD: "Make me look like LINDA RONSTADT again!!"