Browse Source

Fix potential division by 0 if nfactor is not set

djm34
ystarnaud 11 years ago
parent
commit
72590bdcf2
  1. 6
      algorithm.c

6
algorithm.c

@ -667,7 +667,7 @@ void set_algorithm(algorithm_t* algo, const char* newname_alias)
const char* newname; const char* newname;
//load previous algorithm nfactor in case nfactor was applied before algorithm... or default to 10 //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 old_nfactor = ((algo->nfactor)?algo->nfactor:0);
uint8_t nfactor = 0; uint8_t nfactor = 10;
if (!(newname = lookup_algorithm_alias(newname_alias, &nfactor))) if (!(newname = lookup_algorithm_alias(newname_alias, &nfactor)))
newname = newname_alias; newname = newname_alias;
@ -678,9 +678,7 @@ void set_algorithm(algorithm_t* algo, const char* newname_alias)
if ((old_nfactor > 0) && (old_nfactor != nfactor)) if ((old_nfactor > 0) && (old_nfactor != nfactor))
nfactor = old_nfactor; nfactor = old_nfactor;
// Doesn't matter for non-scrypt algorithms set_algorithm_nfactor(algo, nfactor);
if (nfactor > 0)
set_algorithm_nfactor(algo, nfactor);
} }
void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor) void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor)

Loading…
Cancel
Save