From 1810d74b313dcf47df89d6315c2e8d2d1de49631 Mon Sep 17 00:00:00 2001 From: Mark Eichin Date: Sat, 24 Feb 1996 00:01:31 +0000 Subject: [PATCH] * krb5.hin (krb5_x, krb5_xc): wrapper macros to test all function pointers before calling through them (abort if null.) Simplifies debugging on many platforms. Currently #if 1, but could be conditionalized once we're in "production". git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7505 dc483132-0cff-0310-8789-dd5450dbe970 --- src/include/ChangeLog | 7 ++++ src/include/krb5.hin | 83 +++++++++++++++++++++++-------------------- 2 files changed, 52 insertions(+), 38 deletions(-) diff --git a/src/include/ChangeLog b/src/include/ChangeLog index f4c5b00ad..991c1527c 100644 --- a/src/include/ChangeLog +++ b/src/include/ChangeLog @@ -1,3 +1,10 @@ +Fri Feb 23 18:59:18 1996 Mark Eichin + + * krb5.hin (krb5_x, krb5_xc): wrapper macros to test all function + pointers before calling through them (abort if null.) Simplifies + debugging on many platforms. Currently #if 1, but could be + conditionalized once we're in "production". + Wed Feb 21 23:33:18 1996 Richard Basch * Makefile.in: Do not install k5-int.h diff --git a/src/include/krb5.hin b/src/include/krb5.hin index 579268b2b..7c7596607 100644 --- a/src/include/krb5.hin +++ b/src/include/krb5.hin @@ -455,14 +455,21 @@ extern krb5_cksumtype krb5_max_cksum; /* max entry in array */ /* set up *eblockp to use etype */ #define krb5_use_enctype(context, eblockp, enctype) (eblockp)->crypto_entry = krb5_enctype_array[(enctype)]->system -#define krb5_encrypt(context, inptr, outptr, size, eblock, ivec) (*(eblock)->crypto_entry->encrypt_func)(inptr, outptr, size, eblock, ivec) -#define krb5_decrypt(context, inptr, outptr, size, eblock, ivec) (*(eblock)->crypto_entry->decrypt_func)(inptr, outptr, size, eblock, ivec) -#define krb5_process_key(context, eblock, key) (*(eblock)->crypto_entry->process_key)(eblock, key) -#define krb5_finish_key(context, eblock) (*(eblock)->crypto_entry->finish_key)(eblock) -#define krb5_string_to_key(context, eblock, keyblock, data, princ) (*(eblock)->crypto_entry->string_to_key)(eblock, keyblock, data, princ) -#define krb5_init_random_key(context, eblock, keyblock, ptr) (*(eblock)->crypto_entry->init_random_key)(keyblock, ptr) -#define krb5_finish_random_key(context, eblock, ptr) (*(eblock)->crypto_entry->finish_random_key)(ptr) -#define krb5_random_key(context, eblock, ptr, keyblock) (*(eblock)->crypto_entry->random_key)(eblock, ptr, keyblock) +#if 1 +#define krb5_x(ptr,args) ((ptr)?(ptr args):(abort(),1)) +#define krb5_xc(ptr,args) ((ptr)?(ptr args):(abort(),(char*)0)) +#else +#define krb5_x(ptr,args) (ptr args) +#define krb5_xc(ptr,args) (ptr args) +#endif +#define krb5_encrypt(context, inptr, outptr, size, eblock, ivec) krb5_x((*(eblock)->crypto_entry->encrypt_func),(inptr, outptr, size, eblock, ivec)) +#define krb5_decrypt(context, inptr, outptr, size, eblock, ivec) krb5_x((*(eblock)->crypto_entry->decrypt_func),(inptr, outptr, size, eblock, ivec)) +#define krb5_process_key(context, eblock, key) krb5_x((*(eblock)->crypto_entry->process_key),(eblock, key)) +#define krb5_finish_key(context, eblock) krb5_x((*(eblock)->crypto_entry->finish_key),(eblock)) +#define krb5_string_to_key(context, eblock, keyblock, data, princ) krb5_x((*(eblock)->crypto_entry->string_to_key),(eblock, keyblock, data, princ)) +#define krb5_init_random_key(context, eblock, keyblock, ptr) krb5_x((*(eblock)->crypto_entry->init_random_key),(keyblock, ptr)) +#define krb5_finish_random_key(context, eblock, ptr) krb5_x((*(eblock)->crypto_entry->finish_random_key),(ptr)) +#define krb5_random_key(context, eblock, ptr, keyblock) krb5_x((*(eblock)->crypto_entry->random_key),(eblock, ptr, keyblock)) #define krb5_eblock_enctype(context, eblockp) ((eblockp)->crypto_entry->proto_enctype) @@ -470,8 +477,8 @@ extern krb5_cksumtype krb5_max_cksum; /* max entry in array */ * Here's the stuff for the checksum switch: */ #define krb5_checksum_size(context, ctype) (krb5_cksumarray[ctype]->checksum_length) -#define krb5_calculate_checksum(context, ctype, in, in_length, seed, seed_length, outcksum) ((*krb5_cksumarray[ctype]->sum_func)(in, in_length, seed, seed_length, outcksum)) -#define krb5_verify_checksum(context, ctype, cksum, in, in_length, seed, seed_length) ((*krb5_cksumarray[ctype]->sum_verf_func)(cksum, in, in_length, seed, seed_length)) +#define krb5_calculate_checksum(context, ctype, in, in_length, seed, seed_length, outcksum) krb5_x(((*krb5_cksumarray[ctype]->sum_func)),(in, in_length, seed, seed_length, outcksum)) +#define krb5_verify_checksum(context, ctype, cksum, in, in_length, seed, seed_length) krb5_x((*krb5_cksumarray[ctype]->sum_verf_func),(cksum, in, in_length, seed, seed_length)) /* * encryption routine prototypes @@ -1062,19 +1069,19 @@ typedef struct _krb5_cc_ops { /* for set_flags and other functions */ #define KRB5_TC_OPENCLOSE 0x00000001 -#define krb5_cc_initialize(context, cache, principal) (*(cache)->ops->init)(context, cache, principal) -#define krb5_cc_gen_new(context, cache) (*(cache)->ops->gen_new)(context, cache) -#define krb5_cc_destroy(context, cache) (*(cache)->ops->destroy)(context, cache) -#define krb5_cc_close(context, cache) (*(cache)->ops->close)(context, cache) -#define krb5_cc_store_cred(context, cache, creds) (*(cache)->ops->store)(context, cache, creds) -#define krb5_cc_retrieve_cred(context, cache, flags, mcreds, creds) (*(cache)->ops->retrieve)(context, cache, flags, mcreds, creds) -#define krb5_cc_get_principal(context, cache, principal) (*(cache)->ops->get_princ)(context, cache, principal) -#define krb5_cc_start_seq_get(context, cache, cursor) (*(cache)->ops->get_first)(context, cache, cursor) -#define krb5_cc_next_cred(context, cache, cursor, creds) (*(cache)->ops->get_next)(context, cache, cursor, creds) -#define krb5_cc_end_seq_get(context, cache, cursor) (*(cache)->ops->end_get)(context, cache, cursor) -#define krb5_cc_remove_cred(context, cache, flags, creds) (*(cache)->ops->remove_cred)(context, cache,flags, creds) -#define krb5_cc_set_flags(context, cache, flags) (*(cache)->ops->set_flags)(context, cache, flags) -#define krb5_cc_get_name(context, cache) (*(cache)->ops->get_name)(context, cache) +#define krb5_cc_initialize(context, cache, principal) krb5_x((*(cache)->ops->init),(context, cache, principal)) +#define krb5_cc_gen_new(context, cache) krb5_x((*(cache)->ops->gen_new),(context, cache)) +#define krb5_cc_destroy(context, cache) krb5_x((*(cache)->ops->destroy),(context, cache)) +#define krb5_cc_close(context, cache) krb5_x((*(cache)->ops->close),(context, cache)) +#define krb5_cc_store_cred(context, cache, creds) krb5_x((*(cache)->ops->store),(context, cache, creds)) +#define krb5_cc_retrieve_cred(context, cache, flags, mcreds, creds) krb5_x((*(cache)->ops->retrieve),(context, cache, flags, mcreds, creds)) +#define krb5_cc_get_principal(context, cache, principal) krb5_x((*(cache)->ops->get_princ),(context, cache, principal)) +#define krb5_cc_start_seq_get(context, cache, cursor) krb5_x((*(cache)->ops->get_first),(context, cache, cursor)) +#define krb5_cc_next_cred(context, cache, cursor, creds) krb5_x((*(cache)->ops->get_next),(context, cache, cursor, creds)) +#define krb5_cc_end_seq_get(context, cache, cursor) krb5_x((*(cache)->ops->end_get),(context, cache, cursor)) +#define krb5_cc_remove_cred(context, cache, flags, creds) krb5_x((*(cache)->ops->remove_cred),(context, cache,flags, creds)) +#define krb5_cc_set_flags(context, cache, flags) krb5_x((*(cache)->ops->set_flags),(context, cache, flags)) +#define krb5_cc_get_name(context, cache) krb5_xc((*(cache)->ops->get_name),(context, cache)) #define krb5_cc_get_type(context, cache) (*(cache)->ops->prefix) extern krb5_cc_ops FAR *krb5_cc_dfl_ops; @@ -1139,15 +1146,15 @@ krb5_error_code krb5_auth_to_rep krb5_tkt_authent FAR *, krb5_donot_replay FAR *)); -#define krb5_rc_initialize(context, id, span) (*(id)->ops->init)(context, id, span) -#define krb5_rc_recover(context, id) (*(id)->ops->recover)(context, id) -#define krb5_rc_destroy(context, id) (*(id)->ops->destroy)(context, id) -#define krb5_rc_close(context, id) (*(id)->ops->close)(context, id) -#define krb5_rc_store(context, id, dontreplay) (*(id)->ops->store)(context, id, dontreplay) -#define krb5_rc_expunge(context, id) (*(id)->ops->expunge)(context, id) -#define krb5_rc_get_lifespan(context, id, spanp) (*(id)->ops->get_span)(context, id, spanp) -#define krb5_rc_get_name(context, id) (*(id)->ops->get_name)(context, id) -#define krb5_rc_resolve(context, id, name) (*(id)->ops->resolve)(context, id, name) +#define krb5_rc_initialize(context, id, span) krb5_x((*(id)->ops->init),(context, id, span)) +#define krb5_rc_recover(context, id) krb5_x((*(id)->ops->recover),(context, id)) +#define krb5_rc_destroy(context, id) krb5_x((*(id)->ops->destroy),(context, id)) +#define krb5_rc_close(context, id) krb5_x((*(id)->ops->close),(context, id)) +#define krb5_rc_store(context, id, dontreplay) krb5_x((*(id)->ops->store),(context, id, dontreplay)) +#define krb5_rc_expunge(context, id) krb5_x((*(id)->ops->expunge),(context, id)) +#define krb5_rc_get_lifespan(context, id, spanp) krb5_x((*(id)->ops->get_span),(context, id, spanp)) +#define krb5_rc_get_name(context, id) krb5_xc((*(id)->ops->get_name),(context, id)) +#define krb5_rc_resolve(context, id, name) krb5_x((*(id)->ops->resolve),(context, id, name)) extern krb5_rc_ops krb5_rc_dfl_ops; @@ -1232,12 +1239,12 @@ typedef struct _krb5_kt_ops { } krb5_kt_ops; #define krb5_kt_get_type(context, keytab) (*(keytab)->ops->prefix) -#define krb5_kt_get_name(context, keytab, name, namelen) (*(keytab)->ops->get_name)(context, keytab,name,namelen) -#define krb5_kt_close(context, keytab) (*(keytab)->ops->close)(context, keytab) -#define krb5_kt_get_entry(context, keytab, principal, vno, enctype, entry) (*(keytab)->ops->get)(context, keytab, principal, vno, enctype, entry) -#define krb5_kt_start_seq_get(context, keytab, cursor) (*(keytab)->ops->start_seq_get)(context, keytab, cursor) -#define krb5_kt_next_entry(context, keytab, entry, cursor) (*(keytab)->ops->get_next)(context, keytab, entry, cursor) -#define krb5_kt_end_seq_get(context, keytab, cursor) (*(keytab)->ops->end_get)(context, keytab, cursor) +#define krb5_kt_get_name(context, keytab, name, namelen) krb5_x((*(keytab)->ops->get_name),(context, keytab,name,namelen)) +#define krb5_kt_close(context, keytab) krb5_x((*(keytab)->ops->close),(context, keytab)) +#define krb5_kt_get_entry(context, keytab, principal, vno, enctype, entry) krb5_x((*(keytab)->ops->get),(context, keytab, principal, vno, enctype, entry)) +#define krb5_kt_start_seq_get(context, keytab, cursor) krb5_x((*(keytab)->ops->start_seq_get),(context, keytab, cursor)) +#define krb5_kt_next_entry(context, keytab, entry, cursor) krb5_x((*(keytab)->ops->get_next),(context, keytab, entry, cursor)) +#define krb5_kt_end_seq_get(context, keytab, cursor) krb5_x((*(keytab)->ops->end_get),(context, keytab, cursor)) /* remove and add are functions, so that they can return NOWRITE if not a writable keytab */ -- 2.26.2