Browse Source

Use heap ram for coinbase in gen_stratum_work, zeroing it before use.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
5402941691
  1. 3
      cgminer.c

3
cgminer.c

@ -5102,7 +5102,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
len = cb1_len + n1_len + pool->n2size + cb2_len; len = cb1_len + n1_len + pool->n2size + cb2_len;
alloc_len = len; alloc_len = len;
align_len(&alloc_len); align_len(&alloc_len);
coinbase = alloca(alloc_len); coinbase = calloc(alloc_len, 1);
hex2bin(coinbase, pool->swork.coinbase1, cb1_len); hex2bin(coinbase, pool->swork.coinbase1, cb1_len);
hex2bin(coinbase + cb1_len, pool->nonce1, n1_len); hex2bin(coinbase + cb1_len, pool->nonce1, n1_len);
hex2bin(coinbase + cb1_len + n1_len, work->nonce2, pool->n2size); hex2bin(coinbase + cb1_len + n1_len, work->nonce2, pool->n2size);
@ -5110,6 +5110,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
/* Generate merkle root */ /* Generate merkle root */
gen_hash(coinbase, merkle_root, len); gen_hash(coinbase, merkle_root, len);
free(coinbase);
memcpy(merkle_sha, merkle_root, 32); memcpy(merkle_sha, merkle_root, 32);
for (i = 0; i < pool->swork.merkles; i++) { for (i = 0; i < pool->swork.merkles; i++) {
unsigned char merkle_bin[32]; unsigned char merkle_bin[32];

Loading…
Cancel
Save