From bafba9bc6ae06742cb6637cdb38314a59b33bd5d Mon Sep 17 00:00:00 2001 From: ckolivas Date: Tue, 26 Aug 2014 07:57:06 +1000 Subject: [PATCH] Handle workernames with a delimiter but no worker extension --- src/stratifier.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index f4806eeb..0b20f3a2 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1254,11 +1254,12 @@ static json_t *parse_subscribe(int64_t client_id, json_t *params_val) * user or creates a new one. */ static user_instance_t *authorise_user(const char *workername) { - char *username = strdupa(workername); + char *base_username = strdupa(workername), *username; user_instance_t *instance; - username = strsep(&username, "."); - username = strsep(&username, "_"); + username = strsep(&base_username, "._"); + if (!username || !strlen(username)) + username = base_username; if (strlen(username) > 127) username[127] = '\0'; @@ -1392,7 +1393,7 @@ static json_t *parse_authorise(stratum_instance_t *client, json_t *params_val, j *err_val = json_string("Empty workername parameter"); goto out; } - if (!memcmp(buf, ".", 1)) { + if (!memcmp(buf, ".", 1) || !memcmp(buf, "_", 1)) { *err_val = json_string("Empty username parameter"); goto out; }