lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
From: nectar at celabo.org (Jacques A. Vidrine)
Subject: C initialization of static objects (was: ALERT ALERT ALERT! google under attack ALERT ALERT ALERT!)

On Sun, Sep 15, 2002 at 03:05:32AM -0700, silvio@....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@...abo.org>          http://www.celabo.org/
NTT/Verio SME          .     FreeBSD UNIX     .       Heimdal Kerberos
jvidrine@...io.net     .  nectar@...eBSD.org  .          nectar@....se

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ