Re: [Lit.] Buffer overruns
From: Trevor L. Jackson, III (tlj3_at_comcast.net)
Date: 01/29/05
- Next message: David Wagner: "Re: [Lit.] Buffer overruns"
- Previous message: Paul Rubin: "Re: [Lit.] Buffer overruns"
- In reply to: Mok-Kong Shen: "Re: [Lit.] Buffer overruns"
- Next in thread: Mok-Kong Shen: "Re: [Lit.] Buffer overruns"
- Reply: Mok-Kong Shen: "Re: [Lit.] Buffer overruns"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Fri, 28 Jan 2005 21:29:47 -0500
Mok-Kong Shen wrote:
>
>
> Trevor L. Jackson, III wrote:
>
>> Phil Carmody wrote:
>>
>
>>> I don't know if the intent was malicious, but I've see both of these
>>> before #includes:
>>>
>>> #define const
>>> #define private public // OK, not C, but you get the idea
>>>
>>> Some things are almost impossible to defend against.
>>
>>
>>
>> Those symbols are defensible. Just #define them.
>
>
> You are largely but not entirely right, I am afraid. You
> apparently assumed that detection of such matters could
> be perfect, which often may not be the case in practice,
> particularly if the software is of significant size.
> I suppose it is barely possible to eradicate all errors
> (either due to neligence/mistakes or due to intended
> malicious acts), just like one couldn't eradicate all
> drug traffic and abuses in the world. On the other hand,
> taking sufficient measures (all practically feasible
> ones in one's given environment) in defensive (perhaps
> even proactive?) error prevention/recovery is certainly
> a worthwhile/necessary goal to be achieved for all
> safety critical applications.
No I did not make any such assumption. I made the claim that by
#defining the symbols within the source code you control you can inhibit
any preprocessor overrides of those symbols. An alternative is to
#undef them, but that fails silently. I prefer that the conflict be
made visible by an error message regarding dissimilar definitions. Note
that multiple definitions of reserved symbols will not conflict with
each other.
You can even automate it by creating a header file such as define_C.h
and including it as the first header in each source file.
Note that this technique also defends against symbol overrides from the
command line and/or environment.
- Next message: David Wagner: "Re: [Lit.] Buffer overruns"
- Previous message: Paul Rubin: "Re: [Lit.] Buffer overruns"
- In reply to: Mok-Kong Shen: "Re: [Lit.] Buffer overruns"
- Next in thread: Mok-Kong Shen: "Re: [Lit.] Buffer overruns"
- Reply: Mok-Kong Shen: "Re: [Lit.] Buffer overruns"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|