diff options
author | Zhanna Tsitkov <tsitkova@mit.edu> | 2011-03-29 18:52:22 +0000 |
---|---|---|
committer | Zhanna Tsitkov <tsitkova@mit.edu> | 2011-03-29 18:52:22 +0000 |
commit | 772766f5f7d1e3b37f3fc380fb20ea143955ae07 (patch) | |
tree | f504e71cfd18aca61e10a001fb11cc4bdbd4c418 /src | |
parent | 54a459f0c28587fe8ebd83c22830ac786386f3d7 (diff) | |
download | krb5-772766f5f7d1e3b37f3fc380fb20ea143955ae07.tar.gz krb5-772766f5f7d1e3b37f3fc380fb20ea143955ae07.tar.xz krb5-772766f5f7d1e3b37f3fc380fb20ea143955ae07.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/include/krb5/krb5.hin | 2 | ||||
-rw-r--r-- | src/lib/krb5/ccache/ccbase.c | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/include/krb5/krb5.hin b/src/include/krb5/krb5.hin index 0e7fd3fe5d..c28e8571e5 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 6a113346a1..69bb8b876b 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) { |