From: Christian Grothoff Date: Sun, 22 Jan 2017 13:19:12 +0000 (+0100) Subject: fix a few off-by-ones X-Git-Tag: taler-0.2.1~376 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=56d30aad489be8384701d7f2db320c3f75b157e2;p=oweals%2Fgnunet.git fix a few off-by-ones --- diff --git a/src/cadet/gnunet-service-cadet-new_connection.c b/src/cadet/gnunet-service-cadet-new_connection.c index e22202a59..65f45628d 100644 --- a/src/cadet/gnunet-service-cadet-new_connection.c +++ b/src/cadet/gnunet-service-cadet-new_connection.c @@ -294,16 +294,16 @@ send_create (void *cls) cc->task = NULL; GNUNET_assert (GNUNET_YES == cc->mqm_ready); - path_length = GCPP_get_length (cc->path) + 1; + path_length = GCPP_get_length (cc->path); env = GNUNET_MQ_msg_extra (create_msg, - path_length * sizeof (struct GNUNET_PeerIdentity), + (1 + path_length) * sizeof (struct GNUNET_PeerIdentity), GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE); create_msg->cid = cc->cid; pids = (struct GNUNET_PeerIdentity *) &create_msg[1]; pids[0] = my_full_id; - for (unsigned int i=1;i<=path_length;i++) - pids[i] = *GCP_get_id (GCPP_get_peer_at_offset (cc->path, - i - 1)); + for (unsigned int i=0;ipath, + i)); LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending CONNECTION_CREATE message for connection %s\n", GCC_2s (cc)); @@ -685,15 +685,13 @@ GCC_debug (struct CadetConnection *cc, "Connection (NULL)\n"); return; } - s = GCPP_2s (cc->path); LOG2 (level, "Connection %s to %s via path %s in state %d is %s\n", GCC_2s (cc), GCP_2s (cc->destination), - s, + GCPP_2s (cc->path), cc->state, (GNUNET_YES == cc->mqm_ready) ? "ready" : "busy"); - GNUNET_free (s); } /* end of gnunet-service-cadet-new_connection.c */ diff --git a/src/cadet/gnunet-service-cadet-new_paths.c b/src/cadet/gnunet-service-cadet-new_paths.c index bbe9af8b4..926e983c0 100644 --- a/src/cadet/gnunet-service-cadet-new_paths.c +++ b/src/cadet/gnunet-service-cadet-new_paths.c @@ -478,7 +478,7 @@ GCPP_try_path_from_dht (const struct GNUNET_PeerIdentity *get_path, return; } path->hn = hn; - path->entries_length = i; + path->entries_length = i + 1; path->entries = GNUNET_new_array (path->entries_length, struct CadetPeerPathEntry); for (;i>=0;i--)