home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!kithrup!stanford.edu!agate!biosci!uwm.edu!ogicse!flop.ENGR.ORST.EDU!gaia.ucs.orst.edu!umn.edu!noc.msc.net!news.stolaf.edu!guenther
- From: guenther@stolaf.edu (Philip Guenther)
- Newsgroups: comp.os.linux
- Subject: Re: Meaning of "gets unreliable" message?
- Message-ID: <GUENTHER.92Nov18120421@snookles.stolaf.edu>
- Date: 18 Nov 92 20:04:21 GMT
- References: <1992Nov18.103822.7703@rtf.bt.co.uk>
- Sender: news@news.stolaf.edu
- Organization: Academic Computing Center, St. Olaf College
- Lines: 37
- In-Reply-To: grundy@rtf.bt.co.uk's message of 18 Nov 92 10:38:22 GMT
-
- In article <1992Nov18.103822.7703@rtf.bt.co.uk> grundy@rtf.bt.co.uk (Martin Grundy) writes:
- I am running linux-0.98.1 which I down-loaded from hlu's GCC distribution
- from tsx-11-mirror on doc.ic.ac.uk, and it all appears to run very well.
- (Many thanks Linus et al.!).
-
- However, when I try to compile (gcc 2.2.2d and lib4.1) a program that
- uses the gets() function, I get a warning message from the linker (I think)
- that says:
-
- "the `gets' function is unreliable and should not be used"
-
- Despite this message, the programs so far have worked ok.
-
- I haven't seen any other threads on c.o.l about this (yet), and am
- wondering if:
-
- a) the message means what it says, and it will be fixed in lib4.2
- or if b) the message is spurious?
-
- The problem lies in the very idea of gets(). gets() can overfill the
- array you pass it, munching whatever follows. If the array is a
- automatic variable, then it can even overwrite the stack, leading to
- jumps into nowhere. This bug was used by the Morris Internet worm, as
- finger called gets(). The worm would pass the finger daemon on
- another machine a very long carefully crafted string, which would
- overwrite the stack with a jump into the array, where it has just
- placed sopme code! As is, gets() is supposed to be for backward
- compatibility only I believe. To see for yourself that it isn't safe,
- figur out how to pass the program's gets() call a string to long for
- the array that is supposed to contain it.
-
- Philip Guenther
- --
- guenther@stolaf.edu (Philip Guenther) | The ACC might agree with me,
- Student Sys Prog, Academic Computing Center | but with that bunch, (and me)
- St Olaf College, Northfield, MN 55057-1001 | you never know... :-) :-| :-(
- "Life makes sense? LIFE MAKES SENSE!!? Where do people get these ideas?"-me
-