How to use krb5_get_error_message() when context initialization failed?

Petr Spacek pspacek at redhat.com
Tue Feb 26 09:05:51 EST 2013


Hello list,

could somebody point me to the proper way how krb5_get_error_message() can be 
called when krb5_init_context() call failed?

I use krb5-1.10.2 (as shipped in Fedora 17) and my krb5.h contains following 
comment:

/**
  * Get the (possibly extended) error message for a code.
  *
  * @param [in] ctx              Library context
  * @param [in] code             Error code
  *
  * The behavior of krb5_get_error_message() is only defined the first time it
  * is called after a failed call to a krb5 function using the same context, and
  * only when the error code passed in is the same as that returned by the krb5
  * function.
const char * KRB5_CALLCONV
krb5_get_error_message(krb5_context ctx, krb5_error_code code);

I tried following C code snippet and it worked, but I want to ask Kerberos 
experts to be sure that it will not blow up:

krberr = krb5_init_context(&context);
if (krberr)
	krb5_get_error_message(NULL, krberr);


Thank you!

-- 
Petr Spacek


More information about the Kerberos mailing list