Nonce handling fixes

One test had a nonce way too big that was causing issue with the recent refactoring
This commit is contained in:
Alexandre Paillier
2023-04-21 18:15:23 +02:00
parent 3fa410fb24
commit 9735116f50
2 changed files with 12 additions and 10 deletions

View File

@@ -230,18 +230,20 @@ bool tostring256(const uint256_t *const number,
UPPER(LOWER(base)) = 0;
LOWER(LOWER(base)) = baseParam;
uint32_t offset = 0;
if ((baseParam < 2) || (baseParam > 16)) {
if ((outLength == 0) || (baseParam < 2) || (baseParam > 16)) {
return false;
}
do {
if (offset > (outLength - 1)) {
return false;
}
divmod256(&rDiv, &base, &rDiv, &rMod);
out[offset++] = HEXDIGITS[(uint8_t) LOWER(LOWER(rMod))];
} while (!zero256(&rDiv));
} while (!zero256(&rDiv) && (offset < outLength));
if (offset > (outLength - 1)) {
if (offset == outLength) { // destination buffer too small
if (outLength > 3) {
strcpy(out, "...");
} else {
out[0] = '\0';
}
return false;
}