Fix array indexing
authorDavid Barksdale <amatus@amat.us>
Sun, 26 Nov 2017 05:31:58 +0000 (23:31 -0600)
committerDavid Barksdale <amatus@amat.us>
Sun, 26 Nov 2017 05:31:58 +0000 (23:31 -0600)
Found this while investigating #4909, might be related.

src/cadet/gnunet-service-cadet_paths.c

index e75fd393c22d9bad30ee6464cd0f3d3e4738c339..79eed0dccdc4d65190bd916dc209653606748836 100644 (file)
@@ -498,8 +498,8 @@ GCPP_try_path_from_dht (const struct GNUNET_PeerIdentity *get_path,
     const struct GNUNET_PeerIdentity *pid;
 
     pid = (off < get_path_length)
-      ? &get_path[get_path_length - off]
-      : &put_path[get_path_length + put_path_length - off];
+      ? &get_path[get_path_length - off - 1]
+      : &put_path[get_path_length + put_path_length - off - 1];
     cpath[off - skip] = GCP_get (pid,
                                  GNUNET_YES);
     /* Check that no peer is twice on the path */