From 233edaa14c05faf5fd398f57ca081269de0a9948 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Wed, 25 Jul 2012 12:10:20 +0000 Subject: [PATCH] - coverity 10070 --- .../gnunet-service-transport_validation.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 40f57562a..4dadc0f34 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -819,7 +819,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, sig_cache = NULL; sig_cache_exp = NULL; - if (0 < alen) + if (alen > 0) { addrend = memchr (addr, '\0', alen); if (NULL == addrend) @@ -890,6 +890,9 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, 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); @@ -931,7 +934,11 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, 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) { @@ -1101,6 +1108,9 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, 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); -- 2.25.1