diff options
author | Ken Raeburn <raeburn@mit.edu> | 2004-07-29 01:50:02 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@mit.edu> | 2004-07-29 01:50:02 +0000 |
commit | d098bf854cae9c011f9c3b070adc918d2cd06158 (patch) | |
tree | cbadb38ae49d2924f297820a373731b401e88a47 /src/lib/gssapi | |
parent | 0371b3c42e1a5accaef8a8b1ecea1f7350a95c8e (diff) | |
download | krb5-d098bf854cae9c011f9c3b070adc918d2cd06158.tar.gz krb5-d098bf854cae9c011f9c3b070adc918d2cd06158.tar.xz krb5-d098bf854cae9c011f9c3b070adc918d2cd06158.zip |
* set_ccache.c (gss_krb5_ccache_name): Don't make a copy of the string returned
by kg_get_ccache_name. Simplify some calls using a temporary error code
variable.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16629 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/gssapi')
-rw-r--r-- | src/lib/gssapi/krb5/ChangeLog | 4 | ||||
-rw-r--r-- | src/lib/gssapi/krb5/set_ccache.c | 38 |
2 files changed, 13 insertions, 29 deletions
diff --git a/src/lib/gssapi/krb5/ChangeLog b/src/lib/gssapi/krb5/ChangeLog index c5f78eb3fd..4bc52f8238 100644 --- a/src/lib/gssapi/krb5/ChangeLog +++ b/src/lib/gssapi/krb5/ChangeLog @@ -1,5 +1,9 @@ 2004-07-28 Ken Raeburn <raeburn@mit.edu> + * set_ccache.c (gss_krb5_ccache_name): Don't make a copy of the + string returned by kg_get_ccache_name. Simplify some calls using + a temporary error code variable. + * gssapi_krb5.c (kg_get_ccache_name): Make a copy of the default ccache name, because calling krb5_free_context will destroy it. Make the copy always, not just in the local-context case. Check diff --git a/src/lib/gssapi/krb5/set_ccache.c b/src/lib/gssapi/krb5/set_ccache.c index 27422017bd..810c7a050a 100644 --- a/src/lib/gssapi/krb5/set_ccache.c +++ b/src/lib/gssapi/krb5/set_ccache.c @@ -39,7 +39,6 @@ gss_krb5_ccache_name(minor_status, name, out_name) char *old_name = NULL; OM_uint32 err = 0; OM_uint32 minor = 0; - char *gss_out_name; err = gssint_initialize_library(); @@ -54,46 +53,27 @@ gss_krb5_ccache_name(minor_status, name, out_name) const char *tmp_name = NULL; if (!err) { - if (GSS_ERROR(kg_get_ccache_name (&minor, &tmp_name))) { - err = minor; - } - } - - if (!err) { - old_name = malloc(strlen(tmp_name) + 1); - if (old_name == NULL) { - err = ENOMEM; - } else { - strcpy(old_name, tmp_name); - } + kg_get_ccache_name (&err, &tmp_name); } - if (!err) { - char *swap = NULL; - - swap = gss_out_name; - gss_out_name = old_name; - old_name = swap; + old_name = gss_out_name; + gss_out_name = tmp_name; } } - - if (!err) { - if (GSS_ERROR(kg_set_ccache_name (&minor, name))) { - err = minor; - } - } + /* If out_name was NULL, we keep the same gss_out_name value, and + don't free up any storage (leave old_name NULL). */ + + if (!err) + kg_set_ccache_name (&err, name); minor = k5_setspecific(K5_KEY_GSS_KRB5_SET_CCACHE_OLD_NAME, gss_out_name); if (minor) { /* Um. Now what? */ if (err == 0) { err = minor; - if (out_name != NULL) { - *out_name = NULL; - out_name = NULL; - } } free(gss_out_name); + gss_out_name = NULL; } if (!err) { |