mirror of
https://git.openafs.org/openafs.git
synced 2025-01-22 17:00:15 +00:00
Do not call krb5_get_error_message with NULL context
MIT's krb5_get_error_message() ignores the context and can be called with a NULL context. Heimdal's version does not. Change-Id: I31801b0e0044e5e724298404645517e4425b0f09 Reviewed-on: http://gerrit.openafs.org/5508 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Jeffrey Altman <jaltman@openafs.org> Tested-by: Jeffrey Altman <jaltman@openafs.org>
This commit is contained in:
parent
39d5bb10b0
commit
9dd9cfa0e1
@ -211,6 +211,8 @@ void akexit(int exit_code)
|
||||
void
|
||||
redirect_errors(const char *who, afs_int32 code, const char *fmt, va_list ap)
|
||||
{
|
||||
krb5_context context;
|
||||
|
||||
if (who) {
|
||||
fputs(who, stderr);
|
||||
fputs(": ", stderr);
|
||||
@ -219,13 +221,18 @@ redirect_errors(const char *who, afs_int32 code, const char *fmt, va_list ap)
|
||||
int freestr = 0;
|
||||
char *str = (char *)afs_error_message(code);
|
||||
if (strncmp(str, "unknown", strlen(str)) == 0) {
|
||||
str = krb5_get_error_message(NULL, code);
|
||||
freestr = 1;
|
||||
if (krb5_init_context(&context))
|
||||
{
|
||||
str = krb5_get_error_message(NULL, code);
|
||||
freestr = 1;
|
||||
}
|
||||
}
|
||||
fputs(str, stderr);
|
||||
fputs(" ", stderr);
|
||||
if (freestr)
|
||||
krb5_free_error_message(NULL, str);
|
||||
if (freestr) {
|
||||
krb5_free_error_message(context, str);
|
||||
krb5_free_context(context);
|
||||
}
|
||||
}
|
||||
if (fmt) {
|
||||
vfprintf(stderr, fmt, ap);
|
||||
|
@ -55,8 +55,8 @@ khm_krb5_error(krb5_error_code rc, LPCSTR FailedFunctionName,
|
||||
const char *errText;
|
||||
int krb5Error = ((int)(rc & 255));
|
||||
|
||||
if (krb5_get_error_message)
|
||||
errText = krb5_get_error_message(rc);
|
||||
if (*ctx && krb5_get_error_message)
|
||||
errText = krb5_get_error_message(*ctx, rc);
|
||||
else
|
||||
errText = perror_message(rc);
|
||||
_snprintf(message, sizeof(message),
|
||||
@ -64,8 +64,8 @@ khm_krb5_error(krb5_error_code rc, LPCSTR FailedFunctionName,
|
||||
errText,
|
||||
krb5Error,
|
||||
FailedFunctionName);
|
||||
if (krb5_free_error_message)
|
||||
krb5_free_error_message(errText);
|
||||
if (*ctx && krb5_free_error_message)
|
||||
krb5_free_error_message(*ctx, errText);
|
||||
|
||||
MessageBoxA(NULL, message, "Kerberos Five", MB_OK | MB_ICONERROR |
|
||||
MB_TASKMODAL |
|
||||
|
@ -102,7 +102,17 @@ util_AdminErrorCodeTranslate(afs_status_t errorCode, int langId,
|
||||
*errorTextP = afs_error_message(code);
|
||||
#ifdef AFS_KRB5_ERROR_ENV
|
||||
if (strncmp(*errorTextP, "unknown", strlen("unknown")) == 0) {
|
||||
*errorTextP = krb5_get_error_message(NULL, code);
|
||||
krb5_context context;
|
||||
if (!krb5_init_context(&context))
|
||||
{
|
||||
char *msg;
|
||||
msg = krb5_get_error_message(context, code);
|
||||
if (msg) {
|
||||
*errorTextP = strdup(msg);
|
||||
krb5_free_error_message(context, msg);
|
||||
}
|
||||
krb5_free_context(context);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
rc = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user