Skip to content

Commit

Permalink
Use gssalloc in more parts of GSSAPI
Browse files Browse the repository at this point in the history
Fix some GSSAPI buffer allocations which were missed in
800358b: gss_export_sec_context,
gss_display_name, and IAKERB and SPNEGO token construction.

(cherry picked from commit 45e4eaa)

ticket: 7233
  • Loading branch information
greghudson authored and tlyu committed Aug 13, 2012
1 parent b1aa612 commit 7ba6905
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/lib/gssapi/krb5/export_sec_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ krb5_gss_export_sec_context(minor_status, context_handle, interprocess_token)
goto error_out;

/* Allocate the buffer */
if ((obuffer = (krb5_octet *) xmalloc(bufsize)) == NULL) {
if ((obuffer = gssalloc_malloc(bufsize)) == NULL) {
kret = ENOMEM;
goto error_out;
}
Expand Down
6 changes: 4 additions & 2 deletions src/lib/gssapi/krb5/iakerb.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,11 @@ iakerb_make_token(iakerb_ctx_id_t ctx,
else
tokenSize = 2 + data->length;

token->value = q = k5alloc(tokenSize, &code);
if (code != 0)
token->value = q = gssalloc_malloc(tokenSize);
if (q == NULL) {
code = ENOMEM;
goto cleanup;
}
token->length = tokenSize;

if (initialContextToken) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/gssapi/mechglue/g_dsp_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ gss_OID * output_name_type;
}

if ((output_name_buffer->value =
malloc(union_name->external_name->length + 1)) == NULL) {
gssalloc_malloc(union_name->external_name->length + 1)) == NULL) {
if (output_name_type && *output_name_type != GSS_C_NULL_OID) {
(void) generic_gss_release_oid(minor_status,
output_name_type);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/gssapi/mechglue/g_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ OM_uint32 gssint_export_internal_name(minor_status, mech_type,
mechOidTagLen + mechOidDERLen +
mech_type->length +
nameLenLen + dispName.length;
if ((name_buf->value = (void*)malloc(name_buf->length)) ==
if ((name_buf->value = (void*)gssalloc_malloc(name_buf->length)) ==
(void*)NULL) {
name_buf->length = 0;
(void) gss_release_buffer(&status, &dispName);
Expand Down
12 changes: 6 additions & 6 deletions src/lib/gssapi/spnego/spnego_mech.c
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ make_NegHints(OM_uint32 *minor_status,
tlen += 1 + gssint_der_length_size(hintNameSize);
negHintsSize = tlen;

t = (unsigned char *)malloc(tlen);
t = gssalloc_malloc(tlen);
if (t == NULL) {
*minor_status = ENOMEM;
goto errout;
Expand Down Expand Up @@ -3071,7 +3071,7 @@ get_input_token(unsigned char **buff_in, unsigned int buff_length)
return (NULL);

input_token->length = len;
input_token->value = malloc(input_token->length);
input_token->value = gssalloc_malloc(input_token->length);

if (input_token->value == NULL) {
free(input_token);
Expand Down Expand Up @@ -3184,7 +3184,7 @@ put_mech_set(gss_OID_set mechSet, gss_buffer_t buf)
* 0x30 [DER LEN]
*/
tlen = 1 + gssint_der_length_size(ilen) + ilen;
ptr = malloc(tlen);
ptr = gssalloc_malloc(tlen);
if (ptr == NULL)
return -1;

Expand Down Expand Up @@ -3282,7 +3282,7 @@ get_negTokenInit(OM_uint32 *minor_status,
return GSS_S_FAILURE;

tmpbuf.length = ptr - (unsigned char *)tmpbuf.value;
der_mechSet->value = malloc(tmpbuf.length);
der_mechSet->value = gssalloc_malloc(tmpbuf.length);
if (der_mechSet->value == NULL)
return GSS_S_FAILURE;
memcpy(der_mechSet->value, tmpbuf.value, tmpbuf.length);
Expand Down Expand Up @@ -3593,7 +3593,7 @@ make_spnego_tokenInit_msg(spnego_gss_ctx_id_t spnego_ctx,

tlen = g_token_size(gss_mech_spnego, negTokenInitSize);

t = (unsigned char *) malloc(tlen);
t = (unsigned char *) gssalloc_malloc(tlen);

if (t == NULL) {
return (-1);
Expand Down Expand Up @@ -3769,7 +3769,7 @@ make_spnego_tokenTarg_msg(OM_uint32 status, gss_OID mech_wanted,
dataLen += 1 + gssint_der_length_size(NegTokenSize);

tlen = dataLen;
t = (unsigned char *) malloc(tlen);
t = (unsigned char *) gssalloc_malloc(tlen);

if (t == NULL) {
ret = GSS_S_DEFECTIVE_TOKEN;
Expand Down

0 comments on commit 7ba6905

Please sign in to comment.