|
|
@ -2155,12 +2155,12 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg, |
|
|
|
char idstring[20]; |
|
|
|
char idstring[20]; |
|
|
|
uint32_t ntime32; |
|
|
|
uint32_t ntime32; |
|
|
|
uchar hash[32]; |
|
|
|
uchar hash[32]; |
|
|
|
|
|
|
|
int nlen, len; |
|
|
|
time_t now_t; |
|
|
|
time_t now_t; |
|
|
|
json_t *val; |
|
|
|
json_t *val; |
|
|
|
int64_t id; |
|
|
|
int64_t id; |
|
|
|
ts_t now; |
|
|
|
ts_t now; |
|
|
|
FILE *fp; |
|
|
|
FILE *fp; |
|
|
|
int len; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ts_realtime(&now); |
|
|
|
ts_realtime(&now); |
|
|
|
now_t = now.tv_sec; |
|
|
|
now_t = now.tv_sec; |
|
|
@ -2232,9 +2232,16 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg, |
|
|
|
/* Fix broken clients sending too many chars. Nonce2 is part of the
|
|
|
|
/* Fix broken clients sending too many chars. Nonce2 is part of the
|
|
|
|
* read only json so use a temporary variable and modify it. */ |
|
|
|
* read only json so use a temporary variable and modify it. */ |
|
|
|
len = wb->enonce2varlen * 2; |
|
|
|
len = wb->enonce2varlen * 2; |
|
|
|
if ((int)strlen(nonce2) > len) { |
|
|
|
nlen = strlen(nonce2); |
|
|
|
|
|
|
|
if (nlen > len) { |
|
|
|
nonce2 = strdupa(nonce2); |
|
|
|
nonce2 = strdupa(nonce2); |
|
|
|
nonce2[len] = '\0'; |
|
|
|
nonce2[len] = '\0'; |
|
|
|
|
|
|
|
} else if (nlen < len) { |
|
|
|
|
|
|
|
char *tmp = nonce2; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nonce2 = strdupa("0000000000000000"); |
|
|
|
|
|
|
|
memcpy(nonce2, tmp, nlen); |
|
|
|
|
|
|
|
nonce2[len] = '\0'; |
|
|
|
} |
|
|
|
} |
|
|
|
sdiff = submission_diff(client, wb, nonce2, ntime32, nonce, hash); |
|
|
|
sdiff = submission_diff(client, wb, nonce2, ntime32, nonce, hash); |
|
|
|
bswap_256(sharehash, hash); |
|
|
|
bswap_256(sharehash, hash); |
|
|
@ -2245,11 +2252,6 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg, |
|
|
|
json_set_string(json_msg, "reject-reason", SHARE_ERR(err)); |
|
|
|
json_set_string(json_msg, "reject-reason", SHARE_ERR(err)); |
|
|
|
goto out_submit; |
|
|
|
goto out_submit; |
|
|
|
} |
|
|
|
} |
|
|
|
if ((int)strlen(nonce2) < len) { |
|
|
|
|
|
|
|
err = SE_INVALID_NONCE2; |
|
|
|
|
|
|
|
*err_val = JSON_ERR(err); |
|
|
|
|
|
|
|
goto out_unlock; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/* Ntime cannot be less, but allow forward ntime rolling up to max */ |
|
|
|
/* Ntime cannot be less, but allow forward ntime rolling up to max */ |
|
|
|
if (ntime32 < wb->ntime32 || ntime32 > wb->ntime32 + 7000) { |
|
|
|
if (ntime32 < wb->ntime32 || ntime32 > wb->ntime32 + 7000) { |
|
|
|
err = SE_NTIME_INVALID; |
|
|
|
err = SE_NTIME_INVALID; |
|
|
|