From a5d49c625fba61ca1f8cc8b6d0db1c9367558622 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 7 Nov 2013 10:16:57 +0000 Subject: randomization was off by one --- src/ats/libgnunet_plugin_ats_mlp.c | 12 ++++++++++++ src/ats/libgnunet_plugin_ats_proportional.c | 1 - src/ats/perf_ats_solver.c | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ats/libgnunet_plugin_ats_mlp.c b/src/ats/libgnunet_plugin_ats_mlp.c index aef0c1875..ed2cf5987 100644 --- a/src/ats/libgnunet_plugin_ats_mlp.c +++ b/src/ats/libgnunet_plugin_ats_mlp.c @@ -1266,6 +1266,12 @@ GAS_mlp_address_add (void *solver, GNUNET_assert (NULL != solver); GNUNET_assert (NULL != address); + if (GNUNET_ATS_NetworkTypeCount >= network) + { + GNUNET_break (0); + return; + } + if (NULL == address->solver_information) { address->solver_information = GNUNET_new (struct MLP_information); @@ -1429,6 +1435,12 @@ GAS_mlp_address_change_network (void *solver, GNUNET_assert (NULL != solver); GNUNET_assert (NULL != address); + if (GNUNET_ATS_NetworkTypeCount >= new_network) + { + GNUNET_break (0); + return; + } + if (NULL == mlpi) { GNUNET_break (0); diff --git a/src/ats/libgnunet_plugin_ats_proportional.c b/src/ats/libgnunet_plugin_ats_proportional.c index c444adba4..0cbf2d26a 100644 --- a/src/ats/libgnunet_plugin_ats_proportional.c +++ b/src/ats/libgnunet_plugin_ats_proportional.c @@ -1490,7 +1490,6 @@ GAS_proportional_address_add (void *solver, struct ATS_Address *address, struct AddressWrapper *aw = NULL; GNUNET_assert(NULL != s); - net = get_network (s, network); if (NULL == net) { diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c index 20a6cb9ed..91068b4ce 100644 --- a/src/ats/perf_ats_solver.c +++ b/src/ats/perf_ats_solver.c @@ -844,7 +844,7 @@ perf_run () { cur_addr = perf_create_address (cp, ca); /* Add address */ - ph.env.sf.s_add (ph.solver, cur_addr, GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_ATS_NetworkTypeCount + 1)); + ph.env.sf.s_add (ph.solver, cur_addr, GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_ATS_NetworkTypeCount)); ph.current_a = ca + 1; perf_address_initial_update (ph.solver, ph.addresses, cur_addr); GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, -- cgit v1.2.3