You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rampart-dev@ws.apache.org by ka...@apache.org on 2007/08/24 06:28:35 UTC

svn commit: r569242 - in /webservices/rampart/trunk/c/src: omxmlsec/ omxmlsec/openssl/ util/

Author: kaushalye
Date: Thu Aug 23 21:28:32 2007
New Revision: 569242

URL: http://svn.apache.org/viewvc?rev=569242&view=rev
Log:
Memory leak fixes

Modified:
    webservices/rampart/trunk/c/src/omxmlsec/encryption.c
    webservices/rampart/trunk/c/src/omxmlsec/iv.c
    webservices/rampart/trunk/c/src/omxmlsec/openssl/cipher_property.c
    webservices/rampart/trunk/c/src/omxmlsec/sign_ctx.c
    webservices/rampart/trunk/c/src/omxmlsec/sign_part.c
    webservices/rampart/trunk/c/src/omxmlsec/xml_encryption.c
    webservices/rampart/trunk/c/src/omxmlsec/xml_signature.c
    webservices/rampart/trunk/c/src/util/rampart_encryption.c
    webservices/rampart/trunk/c/src/util/rampart_signature.c

Modified: webservices/rampart/trunk/c/src/omxmlsec/encryption.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/encryption.c?rev=569242&r1=569241&r2=569242&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/encryption.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/encryption.c Thu Aug 23 21:28:32 2007
@@ -82,6 +82,8 @@
 
         return AXIS2_FAILURE;
     }
+
+
     ret = openssl_cipher_ctx_set_cipher(oc_ctx,
                                         env,
                                         (EVP_CIPHER*)openssl_get_evp_cipher_by_name(
@@ -168,7 +170,9 @@
         return AXIS2_FAILURE;
     }
 
-    /*Free*/
+    /*FREE*/
+    openssl_cipher_property_free(cprop, env);
+    cprop = NULL;
     AXIS2_FREE(env->allocator, iv);
     iv = NULL;
     openssl_cipher_ctx_free(oc_ctx, env);

Modified: webservices/rampart/trunk/c/src/omxmlsec/iv.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/iv.c?rev=569242&r1=569241&r2=569242&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/iv.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/iv.c Thu Aug 23 21:28:32 2007
@@ -40,6 +40,9 @@
     }
     size = openssl_cipher_property_get_iv_size(cprop, env);
 
+    openssl_cipher_property_free(cprop, env);
+    cprop = NULL;
+    
     /*Here we have predefined IVs in the openssl_constants.
       Get the correct one using the size*/
 

Modified: webservices/rampart/trunk/c/src/omxmlsec/openssl/cipher_property.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/openssl/cipher_property.c?rev=569242&r1=569241&r2=569242&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/openssl/cipher_property.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/openssl/cipher_property.c Thu Aug 23 21:28:32 2007
@@ -225,7 +225,7 @@
 
     if (cprop->cipher)
     {
-        AXIS2_FREE(env->allocator, cprop->cipher);
+        /*AXIS2_FREE(env->allocator, cprop->cipher);*/
         cprop->cipher = NULL;
     }
 

Modified: webservices/rampart/trunk/c/src/omxmlsec/sign_ctx.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/sign_ctx.c?rev=569242&r1=569241&r2=569242&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/sign_ctx.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/sign_ctx.c Thu Aug 23 21:28:32 2007
@@ -18,6 +18,7 @@
 #include <stdio.h>
 #include <axis2_util.h>
 #include <oxs_sign_ctx.h>
+#include <oxs_sign_part.h>
 #include <oxs_error.h>
 
 struct oxs_sign_ctx_t
@@ -290,6 +291,17 @@
 
     if(sign_ctx->sign_parts)
     {    
+        int size = 0;
+        int j = 0;
+        size = axutil_array_list_size(sign_ctx->sign_parts, env);
+        for (j = 0; j < size; j++)
+        {
+            oxs_sign_part_t *sig_part = NULL;
+
+            sig_part = axutil_array_list_get(sign_ctx->sign_parts, env, j);
+            oxs_sign_part_free(sig_part, env);
+            sig_part = NULL;
+        } 
         axutil_array_list_free(sign_ctx->sign_parts, env);
         sign_ctx->sign_parts = NULL;
     }

Modified: webservices/rampart/trunk/c/src/omxmlsec/sign_part.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/sign_part.c?rev=569242&r1=569241&r2=569242&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/sign_part.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/sign_part.c Thu Aug 23 21:28:32 2007
@@ -18,6 +18,7 @@
 #include <stdio.h>
 #include <axis2_util.h>
 #include <oxs_sign_part.h>
+#include <oxs_transform.h>
 #include <oxs_error.h>
 
 struct oxs_sign_part_t
@@ -195,7 +196,23 @@
     }
 
     sign_part->node = NULL;
-    sign_part->transforms = NULL;
+    
+    if(sign_part->transforms){
+        int size = 0;
+        int j = 0;
+        size = axutil_array_list_size(sign_part->transforms, env);
+        for (j = 0; j < size; j++)
+        {
+            oxs_transform_t *tr = NULL;
+
+            tr = axutil_array_list_get(sign_part->transforms, env, j);
+            oxs_transform_free(tr, env);
+            tr = NULL;
+        }
+        axutil_array_list_free(sign_part->transforms, env);
+        sign_part->transforms = NULL;
+    }
+    
 
     AXIS2_FREE(env->allocator,  sign_part);
     sign_part = NULL;

Modified: webservices/rampart/trunk/c/src/omxmlsec/xml_encryption.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/xml_encryption.c?rev=569242&r1=569241&r2=569242&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/xml_encryption.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/xml_encryption.c Thu Aug 23 21:28:32 2007
@@ -253,6 +253,9 @@
     oxs_buffer_free(serialized_buf, env);
     serialized_buf = NULL;
 
+    AXIS2_FREE(env->allocator, serialized_data);
+    serialized_data = NULL;
+
     /*Return success*/
     return AXIS2_SUCCESS;
 }

Modified: webservices/rampart/trunk/c/src/omxmlsec/xml_signature.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/xml_signature.c?rev=569242&r1=569241&r2=569242&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/xml_signature.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/xml_signature.c Thu Aug 23 21:28:32 2007
@@ -216,6 +216,8 @@
     signature_val_node = oxs_token_build_signature_value_element(env, signature_node, signature_val);
 
     /*Free*/
+    AXIS2_FREE(env->allocator , c14nized);
+    c14nized = NULL;
     oxs_buffer_free(input_buf, env);
     input_buf = NULL;
     oxs_buffer_free(output_buf, env);

Modified: webservices/rampart/trunk/c/src/util/rampart_encryption.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/util/rampart_encryption.c?rev=569242&r1=569241&r2=569242&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/util/rampart_encryption.c (original)
+++ webservices/rampart/trunk/c/src/util/rampart_encryption.c Thu Aug 23 21:28:32 2007
@@ -537,9 +537,23 @@
             "[rampart][rampart_encryption]Encrypting signature,Building reference list failed");
         return AXIS2_FAILURE;
     }
-    
-    axutil_array_list_free(id_list, env);
-    id_list = NULL;
-    
+  
+    if(id_list){ 
+        /*TODO need to free data of the list*/
+        int size = 0;    
+        int j = 0; 
+        size = axutil_array_list_size(id_list, env);
+        for (j = 0; j < size; j++)
+        {
+            axis2_char_t *id_temp = NULL;
+
+            id_temp = axutil_array_list_get(id_list, env, j);
+            AXIS2_FREE(env->allocator, id_temp);
+            id_temp = NULL;
+        }
+
+        axutil_array_list_free(id_list, env);
+        id_list = NULL;
+    }
     return AXIS2_SUCCESS;
 }

Modified: webservices/rampart/trunk/c/src/util/rampart_signature.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/util/rampart_signature.c?rev=569242&r1=569241&r2=569242&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/util/rampart_signature.c (original)
+++ webservices/rampart/trunk/c/src/util/rampart_signature.c Thu Aug 23 21:28:32 2007
@@ -242,6 +242,8 @@
             AXIS2_LOG_INFO(env->log,"[rampart][rampart_signature] Binary Security Token creation failed.");
             return AXIS2_FAILURE;
         }
+        oxs_x509_cert_free(cert, env);
+        cert = NULL;
 
     }
     else
@@ -438,7 +440,13 @@
             AXIS2_LOG_INFO(env->log, "[rampart][rampart_signature] Unknown key Identifier type.Token attaching failed");
             status = AXIS2_FAILURE;
         }
+        oxs_x509_cert_free(cert, env);
+        cert = NULL;
     }
+
+
+    AXIS2_FREE(env->allocator, cert_id);
+    cert_id = NULL;
     return status;
 }