proper initialization and disposal of keying material
authorAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 15 Jan 2009 01:52:44 +0000 (01:52 -0000)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 15 Jan 2009 01:52:44 +0000 (01:52 -0000)
src/charon/sa/tasks/child_create.c
src/libstrongswan/chunk.h

index 164bc07..925df04 100644 (file)
@@ -242,7 +242,9 @@ static bool allocate_spi(private_child_create_t *this)
 static status_t select_and_install(private_child_create_t *this, bool no_dh)
 {
        status_t status;
-       chunk_t nonce_i, nonce_r, encr_i, integ_i, encr_r, integ_r;
+       chunk_t nonce_i, nonce_r;
+       chunk_t encr_i = chunk_empty, encr_r = chunk_empty;
+       chunk_t integ_i = chunk_empty, integ_r = chunk_empty;
        linked_list_t *my_ts, *other_ts;
        host_t *me, *other, *other_vip, *my_vip;
        
index d6c2e80..0487fa0 100644 (file)
@@ -151,8 +151,11 @@ static inline void chunk_free(chunk_t *chunk)
  */
 static inline void chunk_clear(chunk_t *chunk)
 {
-       memset(chunk->ptr, 0, chunk->len);
-       chunk_free(chunk);
+       if (chunk->ptr)
+       {
+               memset(chunk->ptr, 0, chunk->len);
+               chunk_free(chunk);
+       }
 }
 
 /**