summaryrefslogtreecommitdiffstats
path: root/hicn-light/src
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2021-01-20 11:29:17 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2021-01-20 11:29:40 +0100
commit2d33dfd939488b81cc4a23f78f949e72391ef236 (patch)
treef954e7df4829b9ccc3fb2fd720a2a46657f6d3b3 /hicn-light/src
parent3b1d7dbd297cba50cbd54be118e549f879b2fc6a (diff)
[HICN-668] Fix leaks + double free
Change-Id: I976659b160654b511f712e65c8439b91d1cabd55 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'hicn-light/src')
-rw-r--r--hicn-light/src/hicn/config/configuration.c28
-rw-r--r--hicn-light/src/hicn/core/mapme.c3
2 files changed, 23 insertions, 8 deletions
diff --git a/hicn-light/src/hicn/config/configuration.c b/hicn-light/src/hicn/config/configuration.c
index c4321299e..e414f05e3 100644
--- a/hicn-light/src/hicn/config/configuration.c
+++ b/hicn-light/src/hicn/config/configuration.c
@@ -1491,13 +1491,25 @@ void configuration_ReceiveCommand(Configuration *config, command_id command,
configuration_SendResponse(config, response, ingressId);
/*
- * For list commands:
- * - deallocate request
- * - deallocate response _payload_
+ * The message is originally received by a listener, and will be freed in
+ * different parts of the code.
*
- * For other commands, generating a ACK/NACK packet:
- * - deallocate request
- * - deallocate response, as the ACK/Nack is allocated
+ * For the special case of commands, a iovec is created, eg in
+ * udpListener::_readCommand, which has to be freed (it is commented in the
+ * listener). On the contrary, the original message is freed.
+ *
+ * From this function, commands are dispatched to different processing
+ * functions, which have two general behaviours:
+ *
+ * - LIST commands:
+ * . a payload for the response is allocated
+ * . a iovec for the response is allocated with header = request header,
+ * payload = newly allocated payload
+ *
+ * - Other commands:
+ * . a ack/nack packet is generated thanks to utils/utils.cc
+ * . this allocates a iovec which reuses the header of the request just
+ * updating the messageType field inside.
*/
parcMemory_Deallocate(&request);
@@ -1507,11 +1519,11 @@ void configuration_ReceiveCommand(Configuration *config, command_id command,
case LIST_LISTENERS:
case LIST_POLICIES:
/* Deallocate payload */
- parcMemory_Deallocate(&response[1] .iov_base);
+ parcMemory_Deallocate(&response[1].iov_base);
break;
default:
- parcMemory_Deallocate(&response);
break;
}
+ parcMemory_Deallocate(&response);
}
diff --git a/hicn-light/src/hicn/core/mapme.c b/hicn-light/src/hicn/core/mapme.c
index 397723a79..4ee3d5bff 100644
--- a/hicn-light/src/hicn/core/mapme.c
+++ b/hicn-light/src/hicn/core/mapme.c
@@ -694,6 +694,9 @@ static bool mapme_onSpecialInterest(const MapMe *mapme,
FIB *fib = forwarder_getFib(mapme->forwarder);
FibEntry *fibEntry = fib_Contains(fib, name);
+
+ name_Release(&name);
+
if (!fibEntry) {
INFO(mapme, "Ignored update with no FIB entry");
return 0;