diff options
author | Simo Sorce <simo@redhat.com> | 2013-04-03 09:57:24 -0400 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2013-04-03 16:39:11 -0400 |
commit | 2a7d19056d58344496fb24d90d0d02915ea83798 (patch) | |
tree | 17b620234f72e9497d0e131a083d2e059ec12425 /proxy/src/mechglue | |
parent | b5fd9388baba101a3ae7b8a2f88164af2083a0a7 (diff) | |
download | gss-proxy-2a7d19056d58344496fb24d90d0d02915ea83798.tar.gz gss-proxy-2a7d19056d58344496fb24d90d0d02915ea83798.tar.xz gss-proxy-2a7d19056d58344496fb24d90d0d02915ea83798.zip |
Fix resource leaks found by Coverity
Signed-off-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'proxy/src/mechglue')
-rw-r--r-- | proxy/src/mechglue/gpp_acquire_cred.c | 4 | ||||
-rw-r--r-- | proxy/src/mechglue/gpp_context.c | 37 | ||||
-rw-r--r-- | proxy/src/mechglue/gpp_creds.c | 1 | ||||
-rw-r--r-- | proxy/src/mechglue/gpp_init_sec_context.c | 4 |
4 files changed, 29 insertions, 17 deletions
diff --git a/proxy/src/mechglue/gpp_acquire_cred.c b/proxy/src/mechglue/gpp_acquire_cred.c index 85d4608..b3a46ec 100644 --- a/proxy/src/mechglue/gpp_acquire_cred.c +++ b/proxy/src/mechglue/gpp_acquire_cred.c @@ -284,7 +284,9 @@ OM_uint32 gssi_acquire_cred_with_password(OM_uint32 *minor_status, * the use of the interposer */ special_mechs = gpp_special_available_mechs(desired_mechs); if (special_mechs == GSS_C_NO_OID_SET) { - return GSS_S_FAILURE; + min = EINVAL; + maj = GSS_S_FAILURE; + goto done; } if (name && name->remote && !name->local) { diff --git a/proxy/src/mechglue/gpp_context.c b/proxy/src/mechglue/gpp_context.c index cb3b172..90dc897 100644 --- a/proxy/src/mechglue/gpp_context.c +++ b/proxy/src/mechglue/gpp_context.c @@ -224,8 +224,8 @@ OM_uint32 gssi_inquire_context(OM_uint32 *minor_status, if (ctx_handle->local) { maj = gss_inquire_context(&min, ctx_handle->local, - src_name ? &s_name->local : NULL, - src_name ? &t_name->local : NULL, + s_name ? &s_name->local : NULL, + s_name ? &t_name->local : NULL, lifetime_rec, &mech_oid, ctx_flags, @@ -234,8 +234,8 @@ OM_uint32 gssi_inquire_context(OM_uint32 *minor_status, } else { maj = gpm_inquire_context(&min, ctx_handle->remote, - src_name ? &s_name->remote : NULL, - src_name ? &t_name->remote : NULL, + s_name ? &s_name->remote : NULL, + s_name ? &t_name->remote : NULL, lifetime_rec, &mech_oid, ctx_flags, @@ -247,16 +247,11 @@ OM_uint32 gssi_inquire_context(OM_uint32 *minor_status, goto done; } - if (mech_type) { - *mech_type = mech_oid; - } - - if (src_name) { + if (s_name) { maj = gpp_copy_oid(&min, mech_oid, &s_name->mech_type); if (maj != GSS_S_COMPLETE) { goto done; } - *src_name = (gss_name_t)s_name; } if (t_name) { @@ -264,12 +259,22 @@ OM_uint32 gssi_inquire_context(OM_uint32 *minor_status, if (maj != GSS_S_COMPLETE) { goto done; } - *targ_name = (gss_name_t)t_name; } done: *minor_status = gpp_map_error(min); - if (maj != GSS_S_COMPLETE) { + if (maj == GSS_S_COMPLETE) { + if (mech_type) { + *mech_type = mech_oid; + } + if (src_name) { + *src_name = (gss_name_t)s_name; + } + if (targ_name) { + *targ_name = (gss_name_t)t_name; + } + } else { + (void)gss_release_oid(&min, &mech_oid); (void)gssi_release_name(&min, (gss_name_t *)&s_name); (void)gssi_release_name(&min, (gss_name_t *)&t_name); } @@ -331,14 +336,16 @@ OM_uint32 gssi_set_sec_context_option(OM_uint32 *minor_status, maj = gpp_remote_to_local_ctx(&min, &ctx->remote, &ctx->local); if (maj != GSS_S_COMPLETE) { *minor_status = gpp_map_error(min); - return maj; + goto done; } } maj = gss_set_sec_context_option(minor_status, &ctx->local, desired_object, value); - if (maj == GSS_S_COMPLETE) { - *context_handle = (gss_ctx_id_t)ctx; +done: + *context_handle = (gss_ctx_id_t)ctx; + if (maj != GSS_S_COMPLETE) { + (void)gssi_delete_sec_context(&min, context_handle, NULL); } return maj; } diff --git a/proxy/src/mechglue/gpp_creds.c b/proxy/src/mechglue/gpp_creds.c index d9c18fe..aaaf577 100644 --- a/proxy/src/mechglue/gpp_creds.c +++ b/proxy/src/mechglue/gpp_creds.c @@ -447,6 +447,7 @@ OM_uint32 gssi_release_cred(OM_uint32 *minor_status, } } + free(cred); *cred_handle = GSS_C_NO_CREDENTIAL; return rmaj; } diff --git a/proxy/src/mechglue/gpp_init_sec_context.c b/proxy/src/mechglue/gpp_init_sec_context.c index 1b233a7..e70e8fc 100644 --- a/proxy/src/mechglue/gpp_init_sec_context.c +++ b/proxy/src/mechglue/gpp_init_sec_context.c @@ -206,10 +206,12 @@ done: } if (maj != GSS_S_COMPLETE && maj != GSS_S_CONTINUE_NEEDED) { free(ctx_handle); - free(cred_handle); *minor_status = gpp_map_error(min); } else { *context_handle = (gss_ctx_id_t)ctx_handle; } + if (claimant_cred_handle == GSS_C_NO_CREDENTIAL) { + free(cred_handle); + } return maj; } |