Browse Source

ckpool - sscanf %s stops at a space

master
kanoi 10 years ago
parent
commit
907a33584e
  1. 18
      src/stratifier.c

18
src/stratifier.c

@ -2375,14 +2375,20 @@ static int send_recv_auth(stratum_instance_t *client)
worker_instance_t *worker = client->worker_instance; worker_instance_t *worker = client->worker_instance;
json_error_t err_val; json_error_t err_val;
json_t *val = NULL; json_t *val = NULL;
int offset = 0;
LOGINFO("Got ckdb response: %s", buf); LOGINFO("Got ckdb response: %s", buf);
response = alloca(responselen); response = alloca(responselen);
memset(response, 0, responselen); memset(response, 0, responselen);
if (unlikely(sscanf(buf, "id.%*d.%s", response) < 1 || strlen(response) < 1 || !strchr(response, '='))) { if (unlikely(sscanf(buf, "id.%*d.%c%n", response, &offset) < 1)) {
LOGWARNING("Got1 unparseable ckdb auth response: %s", buf);
goto out_fail;
}
strcpy(response+1, buf+offset);
if (!strchr(response, '=')) {
if (cmdmatch(response, "failed")) if (cmdmatch(response, "failed"))
goto out; goto out;
LOGWARNING("Got unparseable ckdb auth response: %s", buf); LOGWARNING("Got2 unparseable ckdb auth response: %s", buf);
goto out_fail; goto out_fail;
} }
cmd = response; cmd = response;
@ -3782,9 +3788,11 @@ static void ckdbq_process(ckpool_t *ckp, char *msg)
responselen = strlen(buf); responselen = strlen(buf);
if (likely(responselen > 0)) { if (likely(responselen > 0)) {
char *response = alloca(responselen); char *response = alloca(responselen);
int offset = 0;
memset(response, 0, responselen); memset(response, 0, responselen);
sscanf(buf, "id.%*d.%s", response); if (sscanf(buf, "id.%*d.%c%n", response, &offset) > 0) {
strcpy(response+1, buf+offset);
if (safecmp(response, "ok")) { if (safecmp(response, "ok")) {
char *cmd; char *cmd;
@ -3796,7 +3804,9 @@ static void ckdbq_process(ckpool_t *ckp, char *msg)
parse_ckdb_cmd(ckp, cmd); parse_ckdb_cmd(ckp, cmd);
} }
} else } else
LOGWARNING("Got failed ckdb response: %s", buf); LOGWARNING("Got ckdb failure response: %s", buf);
} else
LOGWARNING("Got bad ckdb response: %s", buf);
free(buf); free(buf);
} }
} }

Loading…
Cancel
Save