From beda377f4ab06a563f8f91768196e1858939e5ec Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 10 Nov 2011 09:50:37 +0000 Subject: [PATCH] handle PONG only if expected --- .../gnunet-service-transport_validation.c | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 29dfb17cc..7e0803a9d 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -245,6 +245,10 @@ struct ValidationEntry */ int in_use; + /** + * Are we expecting a PONG message for this validation entry? + */ + int expecting_pong; }; @@ -488,6 +492,7 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid, gettext_noop ("# PING without HELLO messages sent"), 1, GNUNET_NO); + ve->expecting_pong = GNUNET_YES; } } @@ -591,6 +596,7 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded &timeout_hello_validation, ve); GNUNET_CONTAINER_multihashmap_put (validation_map, &address->peer.hashPubKey, ve, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); + ve->expecting_pong = GNUNET_NO; return ve; } @@ -995,7 +1001,7 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, address.address_length = addrlen; address.transport_name = tname; ve = find_validation_entry (NULL, &address); - if (NULL == ve) + if ((NULL == ve) || (ve->expecting_pong == GNUNET_NO)) { GNUNET_STATISTICS_update (GST_stats, gettext_noop @@ -1010,6 +1016,16 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, return; } + if (GNUNET_OK != + GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, + &pong->purpose, &pong->signature, + &ve->public_key)) + { + GNUNET_break_op (0); + return; + } + + ve->expecting_pong = GNUNET_NO; if (GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (pong->expiration)).rel_value == 0) { @@ -1019,14 +1035,6 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, GNUNET_NO); return; } - if (GNUNET_OK != - GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, - &pong->purpose, &pong->signature, - &ve->public_key)) - { - GNUNET_break_op (0); - return; - } #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Address validated for peer `%s' with plugin `%s': `%s'\n", -- 2.25.1