mirror of
https://git.wownero.com/wownero/wownero-puddle.git
synced 2024-08-15 01:03:20 +00:00
add a sanity check on target size
This commit is contained in:
parent
6b9c012574
commit
7cff0f5d5c
1 changed files with 10 additions and 3 deletions
13
src/pool.c
13
src/pool.c
|
@ -1007,6 +1007,16 @@ target_to_hex(uint64_t target, char *target_hex)
|
||||||
BN_bn2bin(res, &bnb[0]);
|
BN_bn2bin(res, &bnb[0]);
|
||||||
size_t cc = 4 - (32 - BN_num_bytes(res));
|
size_t cc = 4 - (32 - BN_num_bytes(res));
|
||||||
|
|
||||||
|
BN_free(bnt);
|
||||||
|
BN_free(res);
|
||||||
|
|
||||||
|
if (cc > 4 || cc == 0)
|
||||||
|
{
|
||||||
|
log_warn("Requested target too big/small: %llu", target);
|
||||||
|
target_hex[1] = '1';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
char *ph = &target_hex[0];
|
char *ph = &target_hex[0];
|
||||||
while (cc)
|
while (cc)
|
||||||
{
|
{
|
||||||
|
@ -1014,9 +1024,6 @@ target_to_hex(uint64_t target, char *target_hex)
|
||||||
bin_to_hex((const char*)&c, 1, ph++);
|
bin_to_hex((const char*)&c, 1, ph++);
|
||||||
ph++;
|
ph++;
|
||||||
}
|
}
|
||||||
|
|
||||||
BN_free(bnt);
|
|
||||||
BN_free(res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue