#include "gnunet_peerinfo_service.h"
#include "gnunet_signatures.h"
-#define KEEP_093_COMPATIBILITY GNUNET_YES
+#define KEEP_093_COMPATIBILITY GNUNET_NO
/**
* How long is a PONG signature valid? We'll recycle a signature until
sig_cache = NULL;
sig_cache_exp = NULL;
- if (0 < alen)
+ if (alen > 0)
{
addrend = memchr (addr, '\0', alen);
if (NULL == addrend)
sig_cache_exp = &no_address_signature_expiration;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "I am `%s', sending PONG to peer `%s'\n",
+ GNUNET_h2s (&GST_my_identity.hashPubKey),
+ GNUNET_i2s (sender));
+
+ /* message with structure:
+ * [TransportPongMessage][Transport name][Address] */
+
pong = GNUNET_malloc (sizeof (struct TransportPongMessage) + alen + slen);
pong->header.size =
htons (sizeof (struct TransportPongMessage) + alen + slen);
pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN);
pong->challenge = ping->challenge;
pong->addrlen = htonl (alen + slen);
- memcpy (&pong[1], addr, slen);
+ memcpy (&pong[1], addr, slen); /* Copy transport plugin */
#if KEEP_093_COMPATIBILITY
if (GNUNET_YES == buggy)
{
}
else if (alen <= (idsize + strlen (address.transport_name) + 1))
{
- memcpy (&((char *) &pong[1])[slen], &GST_my_identity, alen);
+ memcpy (&((char *) &pong[1])[slen], &GST_my_identity, idsize);
memcpy (&((char *) &pong[1])[slen + idsize], address.transport_name, alen-idsize);
}
else
else
{
#endif
- memcpy (&((char *) &pong[1])[slen], addrend, alen);
+ if (alen > 0)
+ {
+ GNUNET_assert (NULL != addrend);
+ memcpy (&((char *) &pong[1])[slen], addrend, alen);
+ }
if (GNUNET_TIME_absolute_get_remaining (*sig_cache_exp).rel_value <
PONG_SIGNATURE_LIFETIME.rel_value / 4)
{
}
#endif
- GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN,
- &pong->purpose, &pong->signature,
- &GST_my_public_key));
-
GNUNET_assert (sender_address != NULL);
/* first see if the session we got this PING from can be used to transmit
gettext_noop ("# PONG messages received"), 1,
GNUNET_NO);
+ /* message with structure:
+ * [TransportPongMessage][Transport name][Address] */
+
pong = (const struct TransportPongMessage *) hdr;
tname = (const char *) &pong[1];
size = ntohs (hdr->size) - sizeof (struct TransportPongMessage);
&ve->public_key))
{
GNUNET_break_op (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid signature on address %s:%s from peer `%s'\n",
+ tname, GST_plugins_a2s (ve->address),
+ GNUNET_i2s (sender));
return;
}