Better cycle checking in path from DHT
authorDavid Barksdale <amatus@amat.us>
Thu, 28 Dec 2017 00:35:48 +0000 (18:35 -0600)
committerDavid Barksdale <amatus@amat.us>
Thu, 28 Dec 2017 00:35:48 +0000 (18:35 -0600)
src/cadet/gnunet-service-cadet_paths.c

index 7b90fe152d4a6f3c4ddca47e9748d0271ff6bd96..0ec7ff3d71946363f1e8358eabe7648cf8fa5a94 100644 (file)
@@ -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