]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Use gssalloc in more parts of GSSAPI
authorGreg Hudson <ghudson@mit.edu>
Sat, 11 Aug 2012 04:13:05 +0000 (00:13 -0400)
committerTom Yu <tlyu@mit.edu>
Mon, 13 Aug 2012 19:41:55 +0000 (15:41 -0400)
Fix some GSSAPI buffer allocations which were missed in
800358b1790ef82710af0b6021c6ff2dca2b0de7: gss_export_sec_context,
gss_display_name, and IAKERB and SPNEGO token construction.

(cherry picked from commit 45e4eaa298e0dcebef46d07a6acb54cd9affb2ca)

ticket: 7233

src/lib/gssapi/krb5/export_sec_context.c
src/lib/gssapi/krb5/iakerb.c
src/lib/gssapi/mechglue/g_dsp_name.c
src/lib/gssapi/mechglue/g_glue.c
src/lib/gssapi/spnego/spnego_mech.c

index cdd20bd91ff570335f171642dcaae4a8ce1fcb7f..18a3a34cf6be43d5accb4eae8db6632567986fda 100644 (file)
@@ -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;
     }
index 005c3fca3ed90ab0b316fd57e2a4241ae716bd06..dcf417cce961028a2d8a4ec3a52307482319f597 100644 (file)
@@ -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) {
index 2540f21c08252dd136ca17778f21ac7b1167cc9d..825bf4d58b3b70efa2d7ceb7642a229ce3123a21 100644 (file)
@@ -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);
index a9b6f3502fc451f19a3165ed03583adc6a89b872..e9ff4c8075a204761a8a5b94221915e475160a66 100644 (file)
@@ -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);
index 70246b6acb866a36c8a3debf7390ef5a39a98611..8665d4f222e48103d48d5b5f0efc709a1c55587e 100644 (file)
@@ -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;
@@ -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);
@@ -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;
 
@@ -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);
@@ -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);
@@ -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;