Skip to content

Commit

Permalink
Fix oid set construction in gss_inquire_cred()
Browse files Browse the repository at this point in the history
Use gssapi calls to construct the oid sets.  It is not safe on windows
to use malloc to hand-construct the set and then call gss_release_oid_set()
to clean it up.

Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>

ticket: 7227 (new)
tags: pullup
  • Loading branch information
Kevin Wasserman authored and greghudson committed Aug 2, 2012
1 parent 0543b90 commit 4cfdf8d
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/lib/gssapi/mechglue/g_inq_cred.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,42 +123,30 @@ gss_OID_set * mechanisms;
*/

if(mechanisms != NULL) {
status = GSS_S_FAILURE;
mechs = (gss_OID_set) malloc(sizeof(gss_OID_set_desc));
if (mechs == NULL)
goto error;
mechs->count = 0;
mechs->elements = malloc(sizeof(gss_OID_desc) *
(union_cred ? union_cred->count : 1));
if (mechs->elements == NULL)
status = gss_create_empty_oid_set(minor_status, &mechs);
if (GSS_ERROR(status))
goto error;

if (union_cred) {
for (i = 0; i < union_cred->count; i++) {
mechs->elements[i].elements =
malloc(union_cred->mechs_array[i].length);
if (mechs->elements[i].elements == NULL)
status = gss_add_oid_set_member(minor_status,
&union_cred->mechs_array[i],
&mechs);
if (GSS_ERROR(status))
goto error;
g_OID_copy(&mechs->elements[i], &union_cred->mechs_array[i]);
mechs->count++;
}
} else {
mechs->elements[0].elements = malloc(mech->mech_type.length);
g_OID_copy(&mechs->elements[0], &mech->mech_type);
mechs->count++;
status = gss_add_oid_set_member(minor_status,
&mech->mech_type, &mechs);
if (GSS_ERROR(status))
goto error;
}
*mechanisms = mechs;
}

return(GSS_S_COMPLETE);

error:
/*
* cleanup any allocated memory - we can just call
* gss_release_oid_set, because the set is constructed so that
* count always references the currently copied number of
* elements.
*/
if (mechs != NULL)
(void) gss_release_oid_set(&temp_minor_status, &mechs);

Expand Down

0 comments on commit 4cfdf8d

Please sign in to comment.