From: Zhanna Tsitkov Date: Tue, 29 Mar 2011 18:52:22 +0000 (+0000) Subject: In krb5_cc_move if something went wrong, free the dst credential cache X-Git-Tag: krb5-1.10-alpha1~512 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=772766f5f7d1e3b37f3fc380fb20ea143955ae07;p=krb5.git In krb5_cc_move if something went wrong, free the dst credential cache git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24754 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/include/krb5/krb5.hin b/src/include/krb5/krb5.hin index 0e7fd3fe5..c28e8571e 100644 --- a/src/include/krb5/krb5.hin +++ b/src/include/krb5/krb5.hin @@ -2284,7 +2284,7 @@ krb5_cc_get_type(krb5_context context, krb5_ccache cache); * @retval * 0 Sucess; @a src is freed. * @return - * Kerberos error codes; @a src and @a dst are both still allocated. + * Kerberos error codes; @a src is still allocated, while @a dst is freed. */ krb5_error_code KRB5_CALLCONV krb5_cc_move(krb5_context context, krb5_ccache src, krb5_ccache dst); diff --git a/src/lib/krb5/ccache/ccbase.c b/src/lib/krb5/ccache/ccbase.c index 6a113346a..69bb8b876 100644 --- a/src/lib/krb5/ccache/ccbase.c +++ b/src/lib/krb5/ccache/ccbase.c @@ -386,9 +386,13 @@ krb5_cc_move(krb5_context context, krb5_ccache src, krb5_ccache dst) if (!ret) { ret = krb5_cc_initialize(context, dst, princ); } - if (!ret) { - ret = krb5_cc_lock(context, dst); + if (ret) { + krb5_cc_unlock(context, src); + krb5_cccol_unlock(context); + return ret; } + + ret = krb5_cc_lock(context, dst); if (!ret) { ret = krb5_cc_copy_creds(context, src, dst); krb5_cc_unlock(context, dst); @@ -397,6 +401,8 @@ krb5_cc_move(krb5_context context, krb5_ccache src, krb5_ccache dst) krb5_cc_unlock(context, src); if (!ret) { ret = krb5_cc_destroy(context, src); + } else { + ret = krb5_cc_destroy(context, dst); } krb5_cccol_unlock(context); if (princ) {