From 72590bdcf22425de09ac345e98480e2f7c0e6091 Mon Sep 17 00:00:00 2001 From: ystarnaud Date: Tue, 8 Jul 2014 14:34:01 -0400 Subject: [PATCH] Fix potential division by 0 if nfactor is not set --- algorithm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/algorithm.c b/algorithm.c index 8fee479d..8cfbfe07 100644 --- a/algorithm.c +++ b/algorithm.c @@ -667,7 +667,7 @@ void set_algorithm(algorithm_t* algo, const char* newname_alias) const char* newname; //load previous algorithm nfactor in case nfactor was applied before algorithm... or default to 10 uint8_t old_nfactor = ((algo->nfactor)?algo->nfactor:0); - uint8_t nfactor = 0; + uint8_t nfactor = 10; if (!(newname = lookup_algorithm_alias(newname_alias, &nfactor))) newname = newname_alias; @@ -678,9 +678,7 @@ void set_algorithm(algorithm_t* algo, const char* newname_alias) if ((old_nfactor > 0) && (old_nfactor != nfactor)) nfactor = old_nfactor; - // Doesn't matter for non-scrypt algorithms - if (nfactor > 0) - set_algorithm_nfactor(algo, nfactor); + set_algorithm_nfactor(algo, nfactor); } void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor)