Permit NULL context to krb5_get_error_message()
commit9cfb65e883c7219a28bfec8f8878fe6a05953a2c
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 27 Sep 2011 18:21:22 +0000 (27 14:21 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 27 Sep 2011 18:29:52 +0000 (27 14:29 -0400)
tree39c9fb9ec2bfd17f5664a2e8a832b18702224976
parent7fac71db74e2afa2d22cb01110b74e5a4ce2c8a9
Permit NULL context to krb5_get_error_message()

Application developers have a tendency to use krb5_get_error_message()
as a drop in replacement for error_message() and under various
circumstances they pass in a NULL context.  This method works fine
for MIT's implementation which ignores the context but in Heimdal
passing in a NULL context would dump core.

This patch set modifies krb5_get_error_message() in order to
permit the passing of a NULL context.  First, if the context
is NULL, an attempt will be made to allocate one locally for
the purpose of evaluating the error code.  Second, if a local
context cannot be allocated, fall back on calling error_message().
If error_message() fails to return a string, then generate an
"unknown error" response.

Only if all of the above fails is NULL returned.

(cherry picked from commit cbf126bede3a08b6c5ebf4bc88bd4ca5e479a778)

Change-Id: I312fa4f0190b557d659736b2f21ebde4ede8f1da
lib/krb5/error_string.c