From: Alexandra Ellwood Date: Mon, 10 Mar 2008 21:27:30 +0000 (+0000) Subject: cc_remove_cred should only remove one cred X-Git-Tag: krb5-1.7-alpha1~722 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5026edd353101897006cecf70ede3eaca67ace91;p=krb5.git cc_remove_cred should only remove one cred Fixed cc_remove_cred so it only removes the first matching cred. Also fixed the error handling so it returns errors other than CC_NOTFOUND. ticket: new git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20264 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/ccapi/lib/ccapi_v2.c b/src/ccapi/lib/ccapi_v2.c index ffeb1d694..ba2ed4a16 100644 --- a/src/ccapi/lib/ccapi_v2.c +++ b/src/ccapi/lib/ccapi_v2.c @@ -544,36 +544,36 @@ cc_result cc_remove_cred (apiCB *in_context, { cc_result err = ccNoError; cc_credentials_iterator_t iterator = NULL; + cc_uint32 found = 0; - if (!in_context ) { err = cci_check_error (ccErrBadParam); } - if (!in_ccache ) { err = cci_check_error (ccErrBadParam); } + if (!in_context) { err = cci_check_error (ccErrBadParam); } + if (!in_ccache ) { err = cci_check_error (ccErrBadParam); } if (!err) { err = ccapi_ccache_new_credentials_iterator (in_ccache, &iterator); } - while (!err) { + while (!err && !found) { cc_credentials_t creds = NULL; - cc_uint32 equal = 0; err = ccapi_credentials_iterator_next (iterator, &creds); if (!err) { err = cci_cred_union_compare_to_credentials_union (&in_credentials, creds->data, - &equal); + &found); } - if (!err && equal) { + if (!err && found) { err = ccapi_ccache_remove_credentials (in_ccache, creds); } ccapi_credentials_release (creds); } - if (err) { err = cci_check_error (ccErrCredentialsNotFound); } + if (err == ccIteratorEnd) { err = cci_check_error (ccErrCredentialsNotFound); } return cci_remap_error (err); -} +} #if TARGET_OS_MAC #pragma mark -