Re: Is memcpy secure?

From: Mark McIntyre (markmcintyre_at_spamcop.net)
Date: 01/29/04


Date: Thu, 29 Jan 2004 20:30:33 +0000

On 29 Jan 2004 20:11:26 GMT, in comp.lang.c ,
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote:

>In article <christian.bau-8F210D.20071129012004@slb-newsm1.svr.pol.co.uk>,
>Christian Bau <christian.bau@cbau.freeserve.co.uk> wrote:
>:In article <bvbo2b$ctu$1@canopus.cc.umanitoba.ca>,
>: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote:
>
>:> ANSI C -defines- long as being large enough to hold a pointer,
>:> and guarantees that if you convert a pointer to a long and back
>:> again (with no arithmetic operations on the long) then the result
>:> will point to the original object.
>
>:That is news to me. And to many others. Including the guys who wrote the
>:C Standard.
>
>I'll cross-check my references when I next have an opportunity.

The standard says:
6.3.2.3 Pointers
(6) Any pointer type may be converted to an integer type. Except as
previously specified, the result is implementation-defined. If the
result cannot be represented in the integer type, the behavior is
undefined. The result need not be in the range of values of any
integer type.

The "previously specified" refers to null pointers.

-- 
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


Relevant Pages

  • Re: Draft standards OK for new compiler and libc?
    ... the standard says that pointers can be converted to at least ... >> integer type. ... > Conversions that involve pointers (other than as permitted by the ...
    (comp.std.c)
  • Re: Is memcpy secure?
    ... The standard says: ... Any pointer type may be converted to an integer type. ... The "previously specified" refers to null pointers. ... CLC FAQ ...
    (comp.lang.c)
  • Re: Draft standards OK for new compiler and libc?
    ... the standard says that pointers can be converted to at least ... >> integer type. ... > Conversions that involve pointers (other than as permitted by the ...
    (comp.std.c)
  • Re: C90 long
    ... C90 has substantially identical wording, ... I wonder if this integer type, given that it exists at all, should be one ... of the "standard" types or is allowed to be something ... bit longs impossible on a platform that used pointers with full ...
    (comp.std.c)
  • Re: "<>", a relational operator?
    ... And in Standard C there are significant restrictions ... OTOH in BCPL and B pointers were ... has no whole array operations; if you want something done to all (or ... the Standard isn't vague at all -- this is specifically ...
    (comp.lang.fortran)

Quantcast