From 6d274c1a734f249adcc42a0a7d3b28eeb8a5131c Mon Sep 17 00:00:00 2001 From: Aram Date: Wed, 11 May 2016 20:46:34 +0200 Subject: [PATCH] Fixed a bug in the end condition for threads --- libnfc_crypto1_crack.c | 8 ++++++++ solve_bs.c | 8 ++++++++ solve_piwi.c | 8 ++++++++ solve_piwi_bs.c | 8 ++++++++ 4 files changed, 32 insertions(+) diff --git a/libnfc_crypto1_crack.c b/libnfc_crypto1_crack.c index 5e9a905..d1125bf 100644 --- a/libnfc_crypto1_crack.c +++ b/libnfc_crypto1_crack.c @@ -660,6 +660,14 @@ int main (int argc, const char * argv[]) { space = craptev1_get_space(nonces, 95, uid); } if(space){ + // append some zeroes to the end of the space to make sure threads don't go off into the wild + size_t j = 0; + for(j = 0; space[j]; j+=5){ + } + size_t fill = j + (5*thread_count); + for(; j < fill; j++) { + space[j] = 0; + } total_states = craptev1_sizeof_space(space); } else { total_states = 0; diff --git a/solve_bs.c b/solve_bs.c index 6e1efb2..0585d61 100644 --- a/solve_bs.c +++ b/solve_bs.c @@ -49,6 +49,14 @@ int main(int argc, char* argv[]){ total_states = craptev1_sizeof_space(space); thread_count = get_nprocs_conf(); + // append some zeroes to the end of the space to make sure threads don't go off into the wild + size_t j = 0; + for(j = 0; space[j]; j+=5){ + } + size_t fill = j + (5*thread_count); + for(; j < fill; j++) { + space[j] = 0; + } pthread_t threads[thread_count]; size_t i; diff --git a/solve_piwi.c b/solve_piwi.c index 9902468..748fe4e 100644 --- a/solve_piwi.c +++ b/solve_piwi.c @@ -72,6 +72,14 @@ int main(int argc, char* argv[]){ total_states = craptev1_sizeof_space(space); thread_count = get_nprocs_conf(); + // append some zeroes to the end of the space to make sure threads don't go off into the wild + size_t j = 0; + for(j = 0; space[j]; j+=5){ + } + size_t fill = j + (5*thread_count); + for(; j < fill; j++) { + space[j] = 0; + } pthread_t threads[thread_count]; printf("Starting %zu threads to test %zu states\n", thread_count, total_states); size_t i; diff --git a/solve_piwi_bs.c b/solve_piwi_bs.c index 69acd83..a0208fd 100644 --- a/solve_piwi_bs.c +++ b/solve_piwi_bs.c @@ -73,6 +73,14 @@ int main(int argc, char* argv[]){ total_states = craptev1_sizeof_space(space); thread_count = get_nprocs_conf(); + // append some zeroes to the end of the space to make sure threads don't go off into the wild + size_t j = 0; + for(j = 0; space[j]; j+=5){ + } + size_t fill = j + (5*thread_count); + for(; j < fill; j++) { + space[j] = 0; + } pthread_t threads[thread_count]; size_t i;