Full Disclosure mailing list archives
C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!)
From: nectar () celabo org (Jacques A. Vidrine)
Date: Sun, 15 Sep 2002 09:00:36 -0500
On Sun, Sep 15, 2002 at 03:05:32AM -0700, silvio () big net au wrote:
now.. this is true for _unix_ (static will be in bss which is required to be zero'd). but not in terms of C directly, which states that its simply undefined if not initialized. there's alot of this style of unix coding about in software.. which makes the assumption that since its global or static, then it'll be zero.
Programmers make this assumption because it is a true assumption :-) _The C Programming Language_, 2nd edition says it most clearly on p219: ``A static object not explicitly initialized is initialized as if it (or its members) were assigned the constant 0.'' ISO/IEC 9899:1999 (C99) is a bit more verbose (section 6.7.8 paragraph 10): ``If an object that has static storage duration is not initialized explicitly, then: if it has pointer type, it is initialized to a null pointer; if it has arithmetic type, it is initialized to (positive or unsigned) zero; if it is an aggregate, every member is initialized (recursively) according to these rules; if it is a union, the first named member is initialized (recursively) according to these rules. ''
must suck to port :)
Yes, it does, but not for this reason. Cheers, -- Jacques A. Vidrine <nectar () celabo org> http://www.celabo.org/ NTT/Verio SME . FreeBSD UNIX . Heimdal Kerberos jvidrine () verio net . nectar () FreeBSD org . nectar () kth se
Current thread:
- ALERT ALERT ALERT! google under attack ALERT ALERT ALERT! silvio () big net au (Sep 15)
- <Possible follow-ups>
- ALERT ALERT ALERT! google under attack ALERT ALERT ALERT! silvio () big net au (Sep 15)
- C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) Jacques A. Vidrine (Sep 15)
- C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) Jacques A. Vidrine (Sep 15)
- Re: C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) silvio () big net au (Sep 15)
- Re: C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) Michal Zalewski (Sep 15)
- Re: C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) silvio () big net au (Sep 15)
- Re: C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) Dotho (Sep 15)
- Re: C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!) Michal Zalewski (Sep 15)