From 48584ab51c23ea0520869fd373edd4784dd14802 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Wed, 15 Oct 2014 00:55:40 +0000 Subject: - off by one: add own ID to ID array when creating path from DHT --- src/cadet/gnunet-service-cadet_dht.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/cadet') diff --git a/src/cadet/gnunet-service-cadet_dht.c b/src/cadet/gnunet-service-cadet_dht.c index f18e868e3..c9cc51c0b 100644 --- a/src/cadet/gnunet-service-cadet_dht.c +++ b/src/cadet/gnunet-service-cadet_dht.c @@ -119,25 +119,26 @@ path_build_from_dht (const struct GNUNET_PeerIdentity *get_path, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length) { - size_t size = get_path_length + put_path_length; + size_t size = get_path_length + put_path_length + 1; struct GNUNET_PeerIdentity peers[size]; const struct GNUNET_PeerIdentity *peer; struct CadetPeerPath *p; unsigned int own_pos; int i; + peers[0] = my_full_id; LOG (GNUNET_ERROR_TYPE_DEBUG, " GET has %d hops.\n", get_path_length); for (i = 0 ; i < get_path_length; i++) { peer = &get_path[get_path_length - i - 1]; LOG (GNUNET_ERROR_TYPE_DEBUG, " From GET: %s\n", GNUNET_i2s (peer)); - peers[i] = *peer; + peers[i + 1] = *peer; } for (i = 0 ; i < put_path_length; i++) { peer = &put_path[put_path_length - i - 1]; LOG (GNUNET_ERROR_TYPE_DEBUG, " From PUT: %s\n", GNUNET_i2s (peer)); - peers[i + get_path_length] = *peer; + peers[i + get_path_length + 1] = *peer; } p = path_build_from_peer_ids (peers, size, myid, &own_pos); return p; -- cgit v1.2.3