aboutsummaryrefslogtreecommitdiff
path: root/src/cadet
diff options
context:
space:
mode:
authorCarlo von lynX <lynX@time.to.get.psyced.org>2016-07-29 00:35:41 +0000
committerCarlo von lynX <lynX@time.to.get.psyced.org>2016-07-29 00:35:41 +0000
commitc944678c3cc79704d6e16a0790e3044c0fb334a2 (patch)
treebbe2459b7483c74676fb2bad2ffb6b29580ca6ba /src/cadet
parent01a8bbfb74277d3dd7f1c0e24f7ed61554658fd6 (diff)
downloadgnunet-c944678c3cc79704d6e16a0790e3044c0fb334a2.tar.gz
gnunet-c944678c3cc79704d6e16a0790e3044c0fb334a2.zip
fixed a memleak, a static string free, an access of freed memory etc
Diffstat (limited to 'src/cadet')
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c14
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c7
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.c1
3 files changed, 14 insertions, 8 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index 9dfecf043..babb00d66 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -3482,6 +3482,13 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
3482 int droppable; 3482 int droppable;
3483 3483
3484 GCC_check_connections (); 3484 GCC_check_connections ();
3485 fc = fwd ? &c->fwd_fc : &c->bck_fc;
3486 if (0 == fc->queue_max)
3487 {
3488 GNUNET_break (0);
3489 return NULL;
3490 }
3491
3485 size = ntohs (message->size); 3492 size = ntohs (message->size);
3486 data = GNUNET_malloc (size); 3493 data = GNUNET_malloc (size);
3487 GNUNET_memcpy (data, message, size); 3494 GNUNET_memcpy (data, message, size);
@@ -3490,13 +3497,6 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
3490 "--> %s (%s %4u) on conn %s (%p) %s [%5u]\n", 3497 "--> %s (%s %4u) on conn %s (%p) %s [%5u]\n",
3491 GC_m2s (type), GC_m2s (payload_type), payload_id, GCC_2s (c), c, 3498 GC_m2s (type), GC_m2s (payload_type), payload_id, GCC_2s (c), c,
3492 GC_f2s(fwd), size); 3499 GC_f2s(fwd), size);
3493
3494 fc = fwd ? &c->fwd_fc : &c->bck_fc;
3495 if (0 == fc->queue_max)
3496 {
3497 GNUNET_break (0);
3498 return NULL;
3499 }
3500 droppable = GNUNET_NO == force; 3500 droppable = GNUNET_NO == force;
3501 switch (type) 3501 switch (type)
3502 { 3502 {
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index e19c3ca48..fa338f13f 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -787,7 +787,12 @@ peer_destroy (struct CadetPeer *peer)
787 GNUNET_ATS_connectivity_suggest_cancel (peer->connectivity_suggestion); 787 GNUNET_ATS_connectivity_suggest_cancel (peer->connectivity_suggestion);
788 peer->connectivity_suggestion = NULL; 788 peer->connectivity_suggestion = NULL;
789 } 789 }
790 while (NULL != peer->queue_head) 790 /* Following check was 'while' instead of 'if', but GCP_queue_destroy
791 * frees 'peer->queue_head' so the while checks on freed memory.
792 * Not sure if 'if' is what you wanted, but 'while' can't be
793 * correct. --lynX
794 */
795 if (NULL != peer->queue_head)
791 { 796 {
792 GCP_queue_destroy (peer->queue_head, GNUNET_YES, GNUNET_NO, 0); 797 GCP_queue_destroy (peer->queue_head, GNUNET_YES, GNUNET_NO, 0);
793 } 798 }
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c
index bdb8a8ea4..565ddf411 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.c
+++ b/src/cadet/gnunet-service-cadet_tunnel.c
@@ -4252,6 +4252,7 @@ GCT_send_connection_acks (struct CadetTunnel *t)
4252 { 4252 {
4253 continue; 4253 continue;
4254 } 4254 }
4255 GNUNET_assert(cs != 0);
4255 allow_per_connection = to_allow/cs; 4256 allow_per_connection = to_allow/cs;
4256 to_allow -= allow_per_connection; 4257 to_allow -= allow_per_connection;
4257 cs--; 4258 cs--;