From 228ec71055660201d9037425ef48b98cfbcece3c Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 19 May 2014 21:35:06 +1000 Subject: [PATCH] Fix overflow issue with diff in submission_diff --- src/stratifier.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index a2010891..938442df 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1247,8 +1247,7 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg, bool share = false, result = false, invalid = true, submit = false; const char *user, *job_id, *nonce2, *ntime, *nonce; char hexhash[68], sharehash[32], *logdir; - int len, diff, wdiff; - double sdiff = -1; + double diff, wdiff, sdiff = -1; char idstring[20]; uint32_t ntime32; char *fname, *s; @@ -1257,6 +1256,7 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg, uint64_t id; json_t *val; FILE *fp; + int len; memset(hexhash, 0, 68); @@ -1350,16 +1350,16 @@ out_unlock: suffix_string(wdiff, wdiffsuffix, 16, 0); if (sdiff >= diff) { if (new_share(hash, id)) { - LOGINFO("Accepted client %d share diff %.1f/%d/%s: %s", + LOGINFO("Accepted client %d share diff %.1f/%.0f/%s: %s", client->id, sdiff, diff, wdiffsuffix, hexhash); result = true; } else { json_object_set_nocheck(json_msg, "reject-reason", json_string("Duplicate")); - LOGINFO("Rejected client %d dupe diff %.1f/%d/%s: %s", + LOGINFO("Rejected client %d dupe diff %.1f/%.0f/%s: %s", client->id, sdiff, diff, wdiffsuffix, hexhash); } } else { - LOGINFO("Rejected client %d high diff %.1f/%d/%s: %s", + LOGINFO("Rejected client %d high diff %.1f/%.0f/%s: %s", client->id, sdiff, diff, wdiffsuffix, hexhash); json_object_set_nocheck(json_msg, "reject-reason", json_string("Above target")); }