(init_ccapi): return kerberos errors, callers expect it

(acc_get_cache_first): don't leak memory or abort on malloc failure


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16120 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2005-10-03 08:44:18 +00:00
parent fcad6caa4c
commit 1b5f2b7362

View File

@@ -110,7 +110,7 @@ init_ccapi(krb5_context context)
if (cc_handle == NULL) { if (cc_handle == NULL) {
HEIMDAL_MUTEX_unlock(&acc_mutex); HEIMDAL_MUTEX_unlock(&acc_mutex);
krb5_set_error_string(context, "Failed to load %s", lib); krb5_set_error_string(context, "Failed to load %s", lib);
return ccErrServerUnavailable; return KRB5_CC_NOSUPP;
} }
init_func = dlsym(cc_handle, "cc_initialize"); init_func = dlsym(cc_handle, "cc_initialize");
@@ -119,14 +119,14 @@ init_ccapi(krb5_context context)
krb5_set_error_string(context, "Failed to find cc_initialize" krb5_set_error_string(context, "Failed to find cc_initialize"
"in %s: %s", lib, dlerror()); "in %s: %s", lib, dlerror());
dlclose(cc_handle); dlclose(cc_handle);
return ccErrServerUnavailable; return KRB5_CC_NOSUPP;
} }
return 0; return 0;
#else #else
HEIMDAL_MUTEX_unlock(&acc_mutex); HEIMDAL_MUTEX_unlock(&acc_mutex);
krb5_set_error_string(context, "no support for shared object"); krb5_set_error_string(context, "no support for shared object");
return ccErrServerUnavailable; return KRB5_CC_NOSUPP;
#endif #endif
} }
@@ -780,8 +780,10 @@ acc_get_cache_first(krb5_context context, krb5_cc_cursor *cursor)
return ret; return ret;
iter = calloc(1, sizeof(*iter)); iter = calloc(1, sizeof(*iter));
if (iter == NULL) if (iter == NULL) {
abort(); krb5_set_error_string(context, "malloc - out of memory");
return ENOMEM;
}
error = (*init_func)(&iter->context, ccapi_version_3, NULL, NULL); error = (*init_func)(&iter->context, ccapi_version_3, NULL, NULL);
if (error) { if (error) {
@@ -789,8 +791,10 @@ acc_get_cache_first(krb5_context context, krb5_cc_cursor *cursor)
return translate_cc_error(context, error); return translate_cc_error(context, error);
} }
error = (*iter->context->func->new_ccache_iterator)(iter->context, &iter->iter); error = (*iter->context->func->new_ccache_iterator)(iter->context,
&iter->iter);
if (error) { if (error) {
free(iter);
krb5_clear_error_string(context); krb5_clear_error_string(context);
return ENOENT; return ENOENT;
} }