[2242] in Kerberos_V5_Development

home help back first fref pref prev next nref lref last post

Function pointers with krb5_{calculate,verify}_checksum

daemon@ATHENA.MIT.EDU (Ken Hornstein)
Wed Feb 19 09:57:03 1997

To: krbdev@MIT.EDU
Date: Wed, 19 Feb 1997 09:50:49 -0500
From: Ken Hornstein <kenh@cmf.nrl.navy.mil>

First off, let me say up front that the declarations of function pointers is
one of those things in C that I _always_ get wrong and I have to look up in
the book :-)

However, when trying to get Kerberos working on our HP/Convex Exemplar, I
ran across what appears to be a problem with the way the checksum macros
are declared.  I kept getting bus errors anytime checksums were calculated.

In krb5.h, the checksum functions are declared as:

#define krb5_calculate_checksum(context, ctype, in, in_length, seed, seed_length
, outcksum) krb5_x(((*krb5_cksumarray[ctype]->sum_func)),(in, in_length, seed, se
ed_length, outcksum))
#define krb5_verify_checksum(context, ctype, cksum, in, in_length, seed, seed_le
ngth) krb5_x((*krb5_cksumarray[ctype]->sum_verf_func),(cksum, in, in_length, seed
, seed_length))

The extra * on the front of krb5_cksumarray is the puzzling thing.  krb5_x
expands to:

#define krb5_x(ptr,args) ((ptr)?((*(ptr)) args):(abort(),1))

So this ends up being:

*krb5_cksumarray[ctype]->sum_verf_func ?
	*(*krb5_cksumarray[ctype]->sum_verf_func)(...) : (abort(), 1);

Now, color me stupid, but that sure _looks_ like one too many dereferences
to me.  Certainly, none of the _other_ uses of krb5_x have an extra * in them.
Removing the * fixes the problem and makes Kerberos clients work.

Am I way off base here?  The thing that puzzles me is, if this is a problem,
how come it doesn't show up on other architectures?  The new sources work
fine on other architectures.

--Ken

home help back first fref pref prev next nref lref last post