From 1274a09fa1796a1fda007141faa826a6e983d037 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Wed, 27 Aug 2014 12:53:07 +1000 Subject: [PATCH 1/4] Truncate overly long nonce2 strings from broken clients --- src/stratifier.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 0b20f3a2..5799a314 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1731,12 +1731,12 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg, { bool share = false, result = false, invalid = true, submit = false; user_instance_t *user_instance = client->user_instance; - const char *user, *job_id, *nonce2, *ntime, *nonce; double diff = client->diff, wdiff = 0, sdiff = -1; char hexhash[68] = {}, sharehash[32], cdfield[64]; + const char *user, *job_id, *ntime, *nonce; + char *fname = NULL, *s, *nonce2; enum share_err err = SE_NONE; ckpool_t *ckp = client->ckp; - char *fname = NULL, *s; char idstring[20]; uint32_t ntime32; workbase_t *wb; @@ -1772,7 +1772,7 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg, *err_val = JSON_ERR(err); goto out; } - nonce2 = json_string_value(json_array_get(params_val, 2)); + nonce2 = (char *)json_string_value(json_array_get(params_val, 2)); if (unlikely(!nonce2 || !strlen(nonce2))) { err = SE_NO_NONCE2; *err_val = JSON_ERR(err); @@ -1812,6 +1812,9 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg, wdiff = wb->diff; strcpy(idstring, wb->idstring); ASPRINTF(&fname, "%s.sharelog", wb->logdir); + /* Fix broken clients sending too many chars */ + if ((int)strlen(nonce2) > wb->enonce2varlen * 2) + nonce2[wb->enonce2varlen * 2] = '\0'; sdiff = submission_diff(client, wb, nonce2, ntime32, nonce, hash); bswap_256(sharehash, hash); __bin2hex(hexhash, sharehash, 32); @@ -1821,7 +1824,7 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg, json_set_string(json_msg, "reject-reason", SHARE_ERR(err)); goto out_unlock; } - if ((int)strlen(nonce2) != wb->enonce2varlen * 2) { + if ((int)strlen(nonce2) < wb->enonce2varlen * 2) { err = SE_INVALID_NONCE2; *err_val = JSON_ERR(err); goto out_unlock; From 89db28888abe9675c957c296fa3c290b92a76577 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Wed, 27 Aug 2014 12:59:15 +1000 Subject: [PATCH 2/4] Update readme --- README | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README b/README index 425e4c2e..9b5fcf01 100644 --- a/README +++ b/README @@ -4,6 +4,11 @@ Ultra low overhead massively scaleable multi-process, multi-threaded modular bitcoin mining pool, proxy, passthrough, library and database interface in c for Linux. +CKPOOL is code provided free of charge under the GPLv3 license but its development +is mostly paid for by commissioned funding, and the pool by default contributes +0.5% of solved blocks to the development team. Please consider leaving this +contribution in the code or contributing to the authors listed in AUTHORS if you +use this code to aid funding further development. --- LICENSE: From bd510c8f4400796ae9b050b6341a84cefa2731bf Mon Sep 17 00:00:00 2001 From: ckolivas Date: Wed, 27 Aug 2014 13:03:14 +1000 Subject: [PATCH 3/4] Tweak readme --- README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README b/README index 9b5fcf01..00112630 100644 --- a/README +++ b/README @@ -6,9 +6,9 @@ for Linux. CKPOOL is code provided free of charge under the GPLv3 license but its development is mostly paid for by commissioned funding, and the pool by default contributes -0.5% of solved blocks to the development team. Please consider leaving this -contribution in the code or contributing to the authors listed in AUTHORS if you -use this code to aid funding further development. +0.5% of solved blocks in pool mode to the development team. Please consider leaving +this contribution in the code if you are running it on a pool or contributing to the +authors listed in AUTHORS if you use this code to aid funding further development. --- LICENSE: From 89141564f295fbd1c4f38f3884592a38c3b57215 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Wed, 27 Aug 2014 13:06:37 +1000 Subject: [PATCH 4/4] Update ck donation address --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index d99e26af..49448487 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,6 +1,6 @@ Con Kolivas Core project lead, maintainer, author of ckpool and libckpool. -15qSxP1SQcUX3o4nhkfdbgyoWEFMomJ4rZ +14BMjogz69qe8hk9thyzbmR5pg34mVKB1e Andrew Smith Maintainer and author of ckdb.