Re: Why does rewind() ignore errors?
- From: kuyper@xxxxxxxxxx
- Date: 2 Jun 2006 09:02:55 -0700
Dr A. N. Walker wrote:
In article <1149221290.216651.303370@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
<kuyper@xxxxxxxxxx> wrote:
[...]
If you know with a certainty that your input doesn't contain any
over-length lines, it's safe, but such certainty usually reflects
self-delusion, not reality.
Whoa! In your reality, perhaps; but not so in mine; and
I'd guess that my reality matches that of at least a significant
proportion, and perhaps a large majority, of C code being written
[not *used*, but *written*]. ...
I don't know where your reality is; mine includes computers connected
to the internet that cannot, despite the best available security
systems, be kept perfectly clean at all times from unwanted intrusions.
However, while malicious intruders who deliberately misuse a program
are a problem, a far more serious threat (assuming the system has
decent security software that is being used properly) are the ordinary
users who through either stupidity or carelessness or badly written
documentation invoke a program in the wrong context.
In reality, a program that fails
catastrophically when handed input that doesn't match it's input
specifications is usually defective; [...]
... Ditto. ...
There is one exception: some software is deliberately designed to
damage the system it is run on [...]
... No, there are *lots* of exceptions. Most of my
programs have no security, safety or commercial implications,
likewise those of my colleagues or students.
The consequence of buffer overruns isn't just a possible security
violation. It's undefined behaviour. To me, undefined behavior is
serious - as far as the C standard is concerned, there's no limits to
the damage that can occur when the behavior is undefined. Reality is a
little kinder than that, but not a lot. Basically, anything your C
program could have done deliberately by means of code with defined
behavior is something that could occur when the behavior is undefined,
and in most contexts that includes at least one behavior that I REALLY
don't want to have happen; usually, it includes a very large number of
possibilities that I never want to have happen. There's relatively few
contexts, for instance, in which it would be acceptable for a program
to malfunction by deleting or overwriting every file that you have
permission to write to.
If input validation *is* required, what happened to the
notion of a validation *phase*? In Unix-like systems, this is
In my code, I use the standard that the fact that a given piece of code
has defined behavior must be verifiable simply by looking at other code
in the same translation unit; I insert validation code wherever needed
to make that possible. For calls to a function defined in another TU,
this requirement only applies to the arguments and return value of that
function; that the other function works properly is something to be
determined by looking at the TU that it's defined in. Despite the fact
that I break my code into fairly short files (typically no more than a
few hundred lines), I've not found this a burdensome requirement.
Again, if there are security/safety/commercial implications, then
the rest of the pipeline should be somewhat paranoid, but in most
research/academic/domestic applications?
Most research/academic/domestic applications that I'm aware of are run
in contexts where plausible forms of "undefined behavior" includes at
least one completely unacceptable behavior, and usually a LOT more than
one.
.
- Follow-Ups:
- Re: Why does rewind() ignore errors?
- From: Francis Glassborow
- Re: Why does rewind() ignore errors?
- From: Douglas A. Gwyn
- Re: Why does rewind() ignore errors?
- From: Dr A. N. Walker
- Re: Why does rewind() ignore errors?
- References:
- Re: Why does rewind() ignore errors?
- From: Michal Necasek
- Re: Why does rewind() ignore errors?
- From: kuyper
- Re: Why does rewind() ignore errors?
- From: Dr A. N. Walker
- Re: Why does rewind() ignore errors?
- Prev by Date: Re: Why does rewind() ignore errors?
- Next by Date: Re: Why does rewind() ignore errors?
- Previous by thread: Re: Why does rewind() ignore errors?
- Next by thread: Re: Why does rewind() ignore errors?
- Index(es):
Relevant Pages
|