Browse Source

Fix work->target being a 32 byte binary in gen_stratum_work.

Con Kolivas 13 years ago
parent
commit
73d61ca4c3
1 changed files with 6 additions and 3 deletions
  1. 6 3
      cgminer.c

+ 6 - 3
cgminer.c

@@ -4304,6 +4304,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
 	char header[256], hash1[128], *coinbase, *nonce2, *buf;
 	char header[256], hash1[128], *coinbase, *nonce2, *buf;
 	uint32_t *data32, *swap32;
 	uint32_t *data32, *swap32;
 	uint64_t diff, diff64;
 	uint64_t diff, diff64;
+	char target[64];
 	int len, i;
 	int len, i;
 
 
 	mutex_lock(&pool->pool_lock);
 	mutex_lock(&pool->pool_lock);
@@ -4365,13 +4366,15 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
 	/* Generate target as hex where 0x00000000FFFFFFFF is diff 1 */
 	/* Generate target as hex where 0x00000000FFFFFFFF is diff 1 */
 	diff64 = 0x00000000FFFFFFFFULL * diff;
 	diff64 = 0x00000000FFFFFFFFULL * diff;
 	diff64 = ~htobe64(diff64);
 	diff64 = ~htobe64(diff64);
-	sprintf((char *)work->target, "ffffffffffffffffffffffffffffffffffffffffffffffff");
+	sprintf(target, "ffffffffffffffffffffffffffffffffffffffffffffffff");
 	buf = bin2hex((const unsigned char *)&diff64, 8);
 	buf = bin2hex((const unsigned char *)&diff64, 8);
 	if (!buf)
 	if (!buf)
 		quit(1, "Failed to convert diff64 to buf in gen_stratum_work");
 		quit(1, "Failed to convert diff64 to buf in gen_stratum_work");
-	strcat((char *)work->target, buf);
+	strcat(target, buf);
 	free(buf);
 	free(buf);
-	applog(LOG_DEBUG, "Generated target %s", work->target);
+	applog(LOG_DEBUG, "Generated target %s", target);
+	if (!hex2bin(work->target, target, 32))
+		quit(1, "Failed to convert target to bin in gen_stratum_work");
 
 
 	work->pool = pool;
 	work->pool = pool;
 	work->stratum = true;
 	work->stratum = true;