Don't clone chunk in message.get_packet_data
authorMartin Willi <martin@revosec.ch>
Fri, 18 Nov 2011 16:49:53 +0000 (17:49 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:30:44 +0000 (17:30 +0100)
src/conftest/hooks/pretend_auth.c
src/libcharon/encoding/message.c
src/libcharon/encoding/message.h
src/libcharon/sa/ike_sa_manager.c

index dd6ab99..ff99900 100644 (file)
@@ -135,7 +135,7 @@ static void process_auth_request(private_pretend_auth_t *this,
 static void process_init_response(private_pretend_auth_t *this,
                                                                  ike_sa_t *ike_sa, message_t *message)
 {
-       this->ike_init = message->get_packet_data(message);
+       this->ike_init = chunk_clone(message->get_packet_data(message));
 }
 
 /**
index 0789da4..afa9b19 100644 (file)
@@ -1404,7 +1404,7 @@ METHOD(message_t, get_packet_data, chunk_t,
        {
                return chunk_empty;
        }
-       return chunk_clone(this->packet->get_data(this->packet));
+       return this->packet->get_data(this->packet);
 }
 
 METHOD(message_t, parse_header, status_t,
index 20f3c16..dd18b4b 100644 (file)
@@ -344,9 +344,9 @@ struct message_t {
        packet_t * (*get_packet) (message_t *this);
 
        /**
-        * Returns a clone of the internal stored packet_t data.
+        * Returns a chunk pointing to internal packet_t data.
         *
-        * @return                      clone of the internal stored packet_t data.
+        * @return                      packet data.
         */
        chunk_t (*get_packet_data) (message_t *this);
 
index 62f9cc9..5564590 100644 (file)
@@ -1004,11 +1004,10 @@ METHOD(ike_sa_manager_t, checkout_by_message, ike_sa_t*,
        if (is_init && this->hasher)
        {
                /* First request. Check for an IKE_SA with such a message hash. */
-               chunk_t data, hash;
+               chunk_t hash;
 
-               data = message->get_packet_data(message);
-               this->hasher->allocate_hash(this->hasher, data, &hash);
-               chunk_free(&data);
+               this->hasher->allocate_hash(this->hasher,
+                                                                       message->get_packet_data(message), &hash);
 
                if (get_entry_by_hash(this, id, hash, &entry, &segment) == SUCCESS)
                {