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_ERROR,
+ 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);
sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) +
alen + slen);
pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN);
- pong->challenge = ping->challenge;
+ memcpy (&pong->challenge, &ping->challenge, sizeof (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)
{
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);