diff options
author | Julius Bünger <buenger@mytum.de> | 2018-03-08 16:18:19 +0100 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-03-08 16:21:06 +0100 |
commit | b44d319796c027c8c219ea943fc9aa0067e124c1 (patch) | |
tree | 9b010893d2fa9533aa434564b4c74cb368e3cf01 /src/rps | |
parent | 310d0f559656343c4fd849fa517a054c31b24a4e (diff) | |
download | gnunet-b44d319796c027c8c219ea943fc9aa0067e124c1.tar.gz gnunet-b44d319796c027c8c219ea943fc9aa0067e124c1.zip |
rps service: fix memory corruption
Diffstat (limited to 'src/rps')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 12e5b1b3e..dd15dbe3c 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -581,6 +581,7 @@ get_channel (const struct GNUNET_PeerIdentity *peer) | |||
581 | { | 581 | { |
582 | struct PeerContext *peer_ctx; | 582 | struct PeerContext *peer_ctx; |
583 | struct GNUNET_HashCode port; | 583 | struct GNUNET_HashCode port; |
584 | struct GNUNET_PeerIdentity *ctx_peer; | ||
584 | /* There exists a copy-paste-clone in run() */ | 585 | /* There exists a copy-paste-clone in run() */ |
585 | struct GNUNET_MQ_MessageHandler cadet_handlers[] = { | 586 | struct GNUNET_MQ_MessageHandler cadet_handlers[] = { |
586 | GNUNET_MQ_hd_fixed_size (peer_check, | 587 | GNUNET_MQ_hd_fixed_size (peer_check, |
@@ -612,9 +613,11 @@ get_channel (const struct GNUNET_PeerIdentity *peer) | |||
612 | GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_RPS, | 613 | GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_RPS, |
613 | strlen (GNUNET_APPLICATION_PORT_RPS), | 614 | strlen (GNUNET_APPLICATION_PORT_RPS), |
614 | &port); | 615 | &port); |
616 | ctx_peer = GNUNET_new (struct GNUNET_PeerIdentity); | ||
617 | *ctx_peer = *peer; | ||
615 | peer_ctx->send_channel = | 618 | peer_ctx->send_channel = |
616 | GNUNET_CADET_channel_create (cadet_handle, | 619 | GNUNET_CADET_channel_create (cadet_handle, |
617 | (struct GNUNET_PeerIdentity *) peer, /* context */ | 620 | (struct GNUNET_PeerIdentity *) ctx_peer, /* context */ |
618 | peer, | 621 | peer, |
619 | &port, | 622 | &port, |
620 | GNUNET_CADET_OPTION_RELIABLE, | 623 | GNUNET_CADET_OPTION_RELIABLE, |
@@ -2607,6 +2610,7 @@ cleanup_destroyed_channel (void *cls, | |||
2607 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2610 | LOG (GNUNET_ERROR_TYPE_WARNING, |
2608 | "channel (%s) without associated context was destroyed\n", | 2611 | "channel (%s) without associated context was destroyed\n", |
2609 | GNUNET_i2s (peer)); | 2612 | GNUNET_i2s (peer)); |
2613 | GNUNET_free (peer); | ||
2610 | return; | 2614 | return; |
2611 | } | 2615 | } |
2612 | 2616 | ||
@@ -2626,7 +2630,7 @@ cleanup_destroyed_channel (void *cls, | |||
2626 | to_file (file_name_view_log, | 2630 | to_file (file_name_view_log, |
2627 | "-%s\t(cleanup channel, ourself)", | 2631 | "-%s\t(cleanup channel, ourself)", |
2628 | GNUNET_i2s_full (peer)); | 2632 | GNUNET_i2s_full (peer)); |
2629 | //GNUNET_free (peer); | 2633 | GNUNET_free (peer); |
2630 | return; | 2634 | return; |
2631 | } | 2635 | } |
2632 | 2636 | ||
@@ -2642,7 +2646,7 @@ cleanup_destroyed_channel (void *cls, | |||
2642 | { /* We are about to clean the sending channel. Clean the respective | 2646 | { /* We are about to clean the sending channel. Clean the respective |
2643 | * context */ | 2647 | * context */ |
2644 | Peers_cleanup_destroyed_channel (cls, channel); | 2648 | Peers_cleanup_destroyed_channel (cls, channel); |
2645 | //GNUNET_free (peer); | 2649 | GNUNET_free (peer); |
2646 | return; | 2650 | return; |
2647 | } | 2651 | } |
2648 | else | 2652 | else |
@@ -2650,7 +2654,7 @@ cleanup_destroyed_channel (void *cls, | |||
2650 | * open. It probably went down. Remove it from our knowledge. */ | 2654 | * open. It probably went down. Remove it from our knowledge. */ |
2651 | Peers_cleanup_destroyed_channel (cls, channel); | 2655 | Peers_cleanup_destroyed_channel (cls, channel); |
2652 | remove_peer (peer); | 2656 | remove_peer (peer); |
2653 | //GNUNET_free (peer); | 2657 | GNUNET_free (peer); |
2654 | return; | 2658 | return; |
2655 | } | 2659 | } |
2656 | } | 2660 | } |
@@ -2667,7 +2671,7 @@ cleanup_destroyed_channel (void *cls, | |||
2667 | { /* Other peer tried to establish a channel to us twice. We do not accept | 2671 | { /* Other peer tried to establish a channel to us twice. We do not accept |
2668 | * that. Clean the context. */ | 2672 | * that. Clean the context. */ |
2669 | Peers_cleanup_destroyed_channel (cls, channel); | 2673 | Peers_cleanup_destroyed_channel (cls, channel); |
2670 | //GNUNET_free (peer); | 2674 | GNUNET_free (peer); |
2671 | return; | 2675 | return; |
2672 | } | 2676 | } |
2673 | else | 2677 | else |
@@ -2675,7 +2679,7 @@ cleanup_destroyed_channel (void *cls, | |||
2675 | * it. */ | 2679 | * it. */ |
2676 | Peers_cleanup_destroyed_channel (cls, channel); | 2680 | Peers_cleanup_destroyed_channel (cls, channel); |
2677 | clean_peer (peer); | 2681 | clean_peer (peer); |
2678 | //GNUNET_free (peer); | 2682 | GNUNET_free (peer); |
2679 | return; | 2683 | return; |
2680 | } | 2684 | } |
2681 | } | 2685 | } |
@@ -2684,7 +2688,7 @@ cleanup_destroyed_channel (void *cls, | |||
2684 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2688 | LOG (GNUNET_ERROR_TYPE_WARNING, |
2685 | "Destroyed channel is neither sending nor receiving channel\n"); | 2689 | "Destroyed channel is neither sending nor receiving channel\n"); |
2686 | } | 2690 | } |
2687 | //GNUNET_free (peer); | 2691 | GNUNET_free (peer); |
2688 | } | 2692 | } |
2689 | 2693 | ||
2690 | /*********************************************************************** | 2694 | /*********************************************************************** |