From: David Barksdale Date: Sat, 23 Dec 2017 15:54:23 +0000 (-0600) Subject: Check for cycles in cadet paths X-Git-Tag: gnunet-0.11.0rc0~87 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9def71212263b1fcaaa54795a07c97c5b9118a75;p=oweals%2Fgnunet.git Check for cycles in cadet paths I believe this is the underlying issue from commit 012ff13acc0cb2f5d7210aa48819395fecf12a3d. I tested out this change and saw that cyclic paths were dropped and GCP_set_mq() no longer had to deal with multiple removals. After this commit I'll revert that one. --- diff --git a/src/cadet/gnunet-service-cadet_core.c b/src/cadet/gnunet-service-cadet_core.c index a67bbf445..cb213fc54 100644 --- a/src/cadet/gnunet-service-cadet_core.c +++ b/src/cadet/gnunet-service-cadet_core.c @@ -773,10 +773,31 @@ handle_connection_create (void *cls, path_length = size / sizeof (struct GNUNET_PeerIdentity); if (0 == path_length) { - /* bogus request */ + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Dropping CADET_CONNECTION_CREATE with empty path\n"); GNUNET_break_op (0); return; } + /* Check for loops */ + struct GNUNET_CONTAINER_MultiPeerMap *map; + map = GNUNET_CONTAINER_multipeermap_create (path_length, + GNUNET_YES); + GNUNET_assert (NULL != map); + for (off = 0; off < path_length; off++) { + if (GNUNET_SYSERR == + GNUNET_CONTAINER_multipeermap_put (map, + &pids[off], + NULL, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) { + /* bogus request */ + GNUNET_CONTAINER_multipeermap_destroy (map); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Dropping CADET_CONNECTION_CREATE with cyclic path\n"); + GNUNET_break_op (0); + return; + } + } + GNUNET_CONTAINER_multipeermap_destroy (map); /* Initiator is at offset 0. */ for (off=1;off