diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-06-10 14:37:41 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-06-10 14:37:41 +0000 |
commit | 334d64f44f2f741121d0392eb5130bd04428f3ca (patch) | |
tree | 7fe1c4e33f7611f1ad4a7270a4ca45bc5c1045f4 /src/transport | |
parent | 0b5a723229ec82a74fa779052fc190470a00abd1 (diff) | |
download | gnunet-334d64f44f2f741121d0392eb5130bd04428f3ca.tar.gz gnunet-334d64f44f2f741121d0392eb5130bd04428f3ca.zip |
extra checks against connects to self
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 9a79f58ae..eb3e8f9dc 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -2704,6 +2704,13 @@ notify_clients_connect (const struct GNUNET_PeerIdentity *peer, | |||
2704 | uint32_t ats_count; | 2704 | uint32_t ats_count; |
2705 | size_t size; | 2705 | size_t size; |
2706 | 2706 | ||
2707 | if (0 == memcmp (peer, | ||
2708 | &my_identity, | ||
2709 | sizeof (struct GNUNET_PeerIdentity))) | ||
2710 | { | ||
2711 | GNUNET_break (0); | ||
2712 | return; | ||
2713 | } | ||
2707 | #if DEBUG_TRANSPORT | 2714 | #if DEBUG_TRANSPORT |
2708 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2715 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2709 | "Notifying clients about connection from `%s'\n", | 2716 | "Notifying clients about connection from `%s'\n", |
@@ -2717,11 +2724,10 @@ notify_clients_connect (const struct GNUNET_PeerIdentity *peer, | |||
2717 | ats_count = 2; | 2724 | ats_count = 2; |
2718 | size = sizeof (struct ConnectInfoMessage) + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information); | 2725 | size = sizeof (struct ConnectInfoMessage) + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information); |
2719 | if (size > GNUNET_SERVER_MAX_MESSAGE_SIZE) | 2726 | if (size > GNUNET_SERVER_MAX_MESSAGE_SIZE) |
2720 | { | 2727 | { |
2721 | GNUNET_break(0); | 2728 | GNUNET_break(0); |
2722 | } | 2729 | } |
2723 | cim = GNUNET_malloc (size); | 2730 | cim = GNUNET_malloc (size); |
2724 | |||
2725 | cim->header.size = htons (size); | 2731 | cim->header.size = htons (size); |
2726 | cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); | 2732 | cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); |
2727 | cim->ats_count = htonl(2); | 2733 | cim->ats_count = htonl(2); |
@@ -2757,6 +2763,13 @@ notify_clients_disconnect (const struct GNUNET_PeerIdentity *peer) | |||
2757 | struct DisconnectInfoMessage dim; | 2763 | struct DisconnectInfoMessage dim; |
2758 | struct TransportClient *cpos; | 2764 | struct TransportClient *cpos; |
2759 | 2765 | ||
2766 | if (0 == memcmp (peer, | ||
2767 | &my_identity, | ||
2768 | sizeof (struct GNUNET_PeerIdentity))) | ||
2769 | { | ||
2770 | GNUNET_break (0); | ||
2771 | return; | ||
2772 | } | ||
2760 | #if DEBUG_TRANSPORT | 2773 | #if DEBUG_TRANSPORT |
2761 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2774 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2762 | "Notifying clients about lost connection to `%s'\n", | 2775 | "Notifying clients about lost connection to `%s'\n", |
@@ -3309,6 +3322,14 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer, | |||
3309 | struct TransportPlugin *tp; | 3322 | struct TransportPlugin *tp; |
3310 | struct ReadyList *rl; | 3323 | struct ReadyList *rl; |
3311 | 3324 | ||
3325 | if (0 == memcmp (peer, | ||
3326 | &my_identity, | ||
3327 | sizeof (struct GNUNET_PeerIdentity))) | ||
3328 | { | ||
3329 | /* refusing to setup a neighbour entry for myself */ | ||
3330 | GNUNET_break (0); | ||
3331 | return NULL; | ||
3332 | } | ||
3312 | #if DEBUG_TRANSPORT | 3333 | #if DEBUG_TRANSPORT |
3313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3334 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3314 | "Setting up state for neighbour `%4s'\n", | 3335 | "Setting up state for neighbour `%4s'\n", |
@@ -4346,6 +4367,14 @@ handle_pong (void *cls, const struct GNUNET_MessageHeader *message, | |||
4346 | const char *sender_address, | 4367 | const char *sender_address, |
4347 | size_t sender_address_len) | 4368 | size_t sender_address_len) |
4348 | { | 4369 | { |
4370 | if (0 == memcmp (peer, | ||
4371 | &my_identity, | ||
4372 | sizeof (struct GNUNET_PeerIdentity))) | ||
4373 | { | ||
4374 | /* PONG send to self, ignore */ | ||
4375 | return; | ||
4376 | } | ||
4377 | |||
4349 | #if DEBUG_TRANSPORT > 1 | 4378 | #if DEBUG_TRANSPORT > 1 |
4350 | /* we get tons of these that just get discarded, only log | 4379 | /* we get tons of these that just get discarded, only log |
4351 | if we are quite verbose */ | 4380 | if we are quite verbose */ |