Avoid calling gss_release_buffer() from the message-processing code
authorGreg Hudson <ghudson@mit.edu>
Mon, 9 May 2011 18:16:14 +0000 (18:16 +0000)
committerGreg Hudson <ghudson@mit.edu>
Mon, 9 May 2011 18:16:14 +0000 (18:16 +0000)
in lib/gssapi/krb5.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24919 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/gssapi/krb5/k5unsealiov.c
src/lib/gssapi/krb5/util_crypt.c

index 8b67631d9ae2650896e120ceee8928720641fb55..6ca57bc6c0e3dca07d43d7643003ebeca0d240fc 100644 (file)
@@ -599,12 +599,8 @@ kg_unseal_stream_iov(OM_uint32 *minor_status,
                                        tiov, i, toktype);
     if (major_status == GSS_S_COMPLETE)
         *data = *tdata;
-    else if (tdata->type & GSS_IOV_BUFFER_FLAG_ALLOCATED) {
-        OM_uint32 tmp;
-
-        gss_release_buffer(&tmp, &tdata->buffer);
-        tdata->type &= ~(GSS_IOV_BUFFER_FLAG_ALLOCATED);
-    }
+    else
+        kg_release_iov(tdata, 1);
 
 cleanup:
     if (tiov != NULL)
index 2db6ecb196bf366b75ca9811d4c36c6309157214..0063817796bd0d46de6aa5900e36b8a1cb352cc9 100644 (file)
@@ -308,7 +308,6 @@ kg_arcfour_docrypt(const krb5_keyblock *keyblock, int usage,
                    const unsigned char *input_buf, size_t input_len,
                    unsigned char *output_buf)
 {
-    krb5_error_code code;
     krb5_data kd = make_data((char *) kd_data, kd_data_len);
     krb5_crypto_iov kiov;
 
@@ -657,13 +656,14 @@ void
 kg_release_iov(gss_iov_buffer_desc *iov, int iov_count)
 {
     int i;
-    OM_uint32 min_stat;
 
     assert(iov != GSS_C_NO_IOV_BUFFER);
 
     for (i = 0; i < iov_count; i++) {
         if (iov[i].type & GSS_IOV_BUFFER_FLAG_ALLOCATED) {
-            gss_release_buffer(&min_stat, &iov[i].buffer);
+            free(iov[i].buffer.value);
+            iov[i].buffer.length = 0;
+            iov[i].buffer.value = NULL;
             iov[i].type &= ~(GSS_IOV_BUFFER_FLAG_ALLOCATED);
         }
     }
@@ -677,7 +677,6 @@ kg_fixup_padding_iov(OM_uint32 *minor_status, gss_iov_buffer_desc *iov,
     gss_iov_buffer_t data = NULL;
     size_t padlength, relative_padlength;
     unsigned char *p;
-    OM_uint32 minor;
 
     data = kg_locate_iov(iov, iov_count, GSS_IOV_BUFFER_TYPE_DATA);
     padding = kg_locate_iov(iov, iov_count, GSS_IOV_BUFFER_TYPE_PADDING);
@@ -730,11 +729,7 @@ kg_fixup_padding_iov(OM_uint32 *minor_status, gss_iov_buffer_desc *iov,
 
     data->buffer.length -= relative_padlength;
 
-    if (padding->type & GSS_IOV_BUFFER_FLAG_ALLOCATED) {
-        gss_release_buffer(&minor, &padding->buffer);
-        padding->type &= ~(GSS_IOV_BUFFER_FLAG_ALLOCATED);
-    }
-
+    kg_release_iov(padding, 1);
     padding->buffer.length = 0;
     padding->buffer.value = NULL;