stratum: prevent spaces in the username

that was possible since decred 35 chars workaround...
This commit is contained in:
Tanguy Pruvot 2016-03-15 03:46:46 +01:00
parent 266f78431a
commit 5116ea9f65

View file

@ -181,16 +181,17 @@ bool client_authorize(YAAMP_CLIENT *client, json_value *json_params)
{
strncpy(client->username, json_params->u.array.values[0]->u.string.ptr, 1023);
if (client->username[0] == ' ')
return false;
char sep = client->username[34];
if (sep == '.' || sep == ',' || sep == ':') {
client->username[34] = 0;
if (sep == '.' || sep == ',' || sep == ':' || sep == ' ') {
client->username[34] = '\0';
strncpy(client->worker, client->username+35, 1023-35);
// debuglog("%s\n", client->username);
// debuglog("%s\n", client->worker);
} else if (strlen(client->username) > 35) {
client->username[35] = 0;
} else if (strlen(client->username) > 35 && client->username[0] >= 'D') {
// 35 chars allowed for decred...
client->username[35] = '\0';
strncpy(client->worker, client->username+36, 1023-36);
debuglog("address %s was too long, truncated to 35 chars\n", client->username);
}
}