Clearing credentials question

Russ Allbery rra at
Fri Jan 7 12:49:20 EST 2011

wollman at (Garrett Wollman) writes:

> Well, technically, Standard C says you're supposed to:

> 	static const krb5_creds zero_initialized_creds;
> 	krb5_creds creds = zero_initialized_creds;

> Nobody ever does this.

Yeah, I always cringe when I write the memset() code, since there's no
guarantee whatsoever that all-bits-zero is a NULL pointer.  But of course
in practice every platform on which MIT Kerberos could conceivably compile
(for unrelated reasons) uses all-bits-zero as a NULL pointer, so as you
mention it's only a pedantic concern.

> Kerberos developers could follow the example of POSIX threads and
> provide a manifest constant so that clients could do:

> 	krb5_creds creds = KRB5_CREDS_INITIALIZER;

> give some additional clarity.  A good compiler will optimize
> this initializer (which in C99 but not C89/C90 could be made a real
> rvalue) into the memset call, whereas it may not be able to do the
> same for the zero_initialized_creds version.

That would be nice, actually, although only for satisfying my feelings of
strict standards compliance.  :)

Russ Allbery (rra at             <>

More information about the Kerberos mailing list