From f4f75ed70d46464bf613d87d71552770fab8b6bf Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Wed, 27 Dec 2017 18:35:48 -0600 Subject: [PATCH] Better cycle checking in path from DHT --- src/cadet/gnunet-service-cadet_paths.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/cadet/gnunet-service-cadet_paths.c b/src/cadet/gnunet-service-cadet_paths.c index 7b90fe152..0ec7ff3d7 100644 --- a/src/cadet/gnunet-service-cadet_paths.c +++ b/src/cadet/gnunet-service-cadet_paths.c @@ -501,6 +501,14 @@ GCPP_try_path_from_dht (const struct GNUNET_PeerIdentity *get_path, pid = (off < get_path_length) ? &get_path[get_path_length - off - 1] : &put_path[get_path_length + put_path_length - off - 1]; + /* Check that I am not in the path */ + if (0 == memcmp (&my_full_id, + pid, + sizeof (struct GNUNET_PeerIdentity))) + { + skip = off + 1; + continue; + } cpath[off - skip] = GCP_get (pid, GNUNET_YES); /* Check that no peer is twice on the path */ @@ -513,6 +521,12 @@ GCPP_try_path_from_dht (const struct GNUNET_PeerIdentity *get_path, } } } + if (skip >= total_len) + { + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Path discovered from DHT is one big cycle?\n"); + return; + } total_len -= skip; /* First figure out if this path is a subset of an existing path, an -- 2.25.1