Re: why the usage of gets() is dangerous.
- From: "Malcolm McLean" <regniztar@xxxxxxxxxxxxxx>
- Date: Fri, 16 Nov 2007 23:19:12 -0000
"Richard Heathfield" <rjh@xxxxxxxxxxxxxxx> wrote in message
We'll declare that pointer cosist of three values - the address, the start of the object, and the end of the object.It is possible,
though rather difficult, to implement a safe gets(), that is to say one
that always terminates the program with an error message if the buffer is
exceeded.
Show me.
Now in the write to array code we specify that if the address execceds the end of the object, the program is to terminate with an error meaage.
With this device we have a perfectly safe gets() fucntion. It cannot return an incorrect string, or corrupt another variable, or put little elves on screen. It can only fill the buffer correctly or report that it has been exceeded.
>
Time after time it has been shown that this is not the case. Very often people treat incomplete reads as full lines. So if the line contains a drug dose your fgets() - enabled machine might deliver only one tenth of the amount needed, given an off by one line length error.What is not possible to is implement is a safe fgets(), that is to say,
one that can be used safely given the limitations of the average human
programmer.
The fgets function is very easy to use safely.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm
.
- Follow-Ups:
- Re: why the usage of gets() is dangerous.
- From: Flash Gordon
- Re: why the usage of gets() is dangerous.
- From: $)CHarald van D)&k
- Re: why the usage of gets() is dangerous.
- From: CBFalconer
- Re: why the usage of gets() is dangerous.
- From: Richard Heathfield
- Re: why the usage of gets() is dangerous.
- References:
- why the usage of gets() is dangerous.
- From: jayapal
- Re: why the usage of gets() is dangerous.
- From: Paul Hsieh
- Re: why the usage of gets() is dangerous.
- From: Malcolm McLean
- Re: why the usage of gets() is dangerous.
- From: Richard Heathfield
- why the usage of gets() is dangerous.
- Prev by Date: Re: "Criticism of the C programming language ??????"
- Next by Date: Re: "Criticism of the C programming language ??????"
- Previous by thread: Re: why the usage of gets() is dangerous.
- Next by thread: Re: why the usage of gets() is dangerous.
- Index(es):
Relevant Pages
|