home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / linux / 17107 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  2.3 KB

  1. 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
  2. From: guenther@stolaf.edu (Philip Guenther)
  3. Newsgroups: comp.os.linux
  4. Subject: Re: Meaning of "gets unreliable" message?
  5. Message-ID: <GUENTHER.92Nov18120421@snookles.stolaf.edu>
  6. Date: 18 Nov 92 20:04:21 GMT
  7. References: <1992Nov18.103822.7703@rtf.bt.co.uk>
  8. Sender: news@news.stolaf.edu
  9. Organization: Academic Computing Center, St. Olaf College
  10. Lines: 37
  11. In-Reply-To: grundy@rtf.bt.co.uk's message of 18 Nov 92 10:38:22 GMT
  12.  
  13. In article <1992Nov18.103822.7703@rtf.bt.co.uk> grundy@rtf.bt.co.uk (Martin Grundy) writes:
  14.    I am running linux-0.98.1 which I down-loaded from hlu's GCC distribution
  15.    from tsx-11-mirror on doc.ic.ac.uk, and it all appears to run very well.
  16.    (Many thanks Linus et al.!).
  17.  
  18.    However, when I try to compile (gcc 2.2.2d and lib4.1) a program that
  19.    uses the gets() function, I get a warning message from the linker (I think)
  20.    that says:
  21.  
  22.        "the `gets' function is unreliable and should not be used"
  23.  
  24.    Despite this message, the programs so far have worked ok.
  25.  
  26.    I haven't seen any other threads on c.o.l about this (yet), and am
  27.    wondering if:
  28.  
  29.        a) the message means what it says, and it will be fixed in lib4.2
  30.    or if   b) the message is spurious?
  31.  
  32. The problem lies in the very idea of gets().  gets() can overfill the
  33. array you pass it, munching whatever follows.  If the array is a
  34. automatic variable, then it can even overwrite the stack, leading to
  35. jumps into nowhere.  This bug was used by the Morris Internet worm, as
  36. finger called gets().  The worm would pass the finger daemon on
  37. another machine a very long carefully crafted string, which would
  38. overwrite the stack with a jump into the array, where it has just
  39. placed sopme code!  As is, gets() is supposed to be for backward
  40. compatibility only I believe.  To see for yourself that it isn't safe,
  41. figur out how to pass the program's gets() call a string to long for
  42. the array that is supposed to contain it.
  43.  
  44. Philip Guenther
  45. --
  46. guenther@stolaf.edu (Philip Guenther)       | The ACC might agree with me,
  47. Student Sys Prog, Academic Computing Center | but with that bunch, (and me)
  48. St Olaf College, Northfield, MN 55057-1001  | you never know... :-) :-| :-(
  49. "Life makes sense?  LIFE MAKES SENSE!!?  Where do people get these ideas?"-me
  50.