Path: utzoo!attcan!uunet!wyse!vsi1!ames!elroy!gryphon!vector!rpp386!jfh From: jfh@rpp386.Dallas.TX.US (John F. Haugh II) Newsgroups: comp.sources.d Subject: Re: v05i053: A "safe" replacement for gets() Message-ID: <8709@rpp386.Dallas.TX.US> Date: 19 Nov 88 15:23:53 GMT References: <674@quintus.UUCP> Reply-To: jfh@rpp386.Dallas.TX.US (John F. Haugh II) Organization: River Parishes Programming, Dallas TX Lines: 17 In article <674@quintus.UUCP> ok@quintus.UUCP 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] No, if `s' is `char *s' instead of `char s[BUFSIZ]', sizeof s == some small number [ 2 or 4 or something like that ]. A more correct solution would be to re-write gets() to expect a buffer of size BUFSIZ, or else have the buffer size passed as an argument. -- John F. Haugh II +----------Quote of the Week:---------- VoiceNet: (214) 250-3311 Data: -6272 | "Okay, so maybe Berkeley is in north- InterNet: jfh@rpp386.Dallas.TX.US | ern California." -- Henry Spencer UucpNet : !killer!rpp386!jfh +--------------------------------------