Skip to content

Commit f67feeb

Browse files
committed
protocol: fix auth token check
1 parent 96e88fb commit f67feeb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/protocol.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,17 @@ int callback_tty(struct lws *wsi, enum lws_callback_reasons reason, void *user,
284284
if (pss->process != NULL) break;
285285
uint16_t columns = 0;
286286
uint16_t rows = 0;
287-
char *token = NULL;
288287
json_object *obj = parse_window_size(pss->buffer, pss->len, &columns, &rows);
289288
if (server->credential != NULL) {
290289
struct json_object *o = NULL;
291290
if (json_object_object_get_ex(obj, "AuthToken", &o)) {
292291
const char *token = json_object_get_string(o);
293-
pss->authenticated = token != NULL && !strcmp(token, server->credential);
292+
if (token != NULL && !strcmp(token, server->credential))
293+
pss->authenticated = true;
294+
else
295+
lwsl_warn("WS authentication failed with token: %s\n", token);
294296
}
295297
if (!pss->authenticated) {
296-
lwsl_warn("WS authentication failed with token: %s\n", token);
297298
json_object_put(obj);
298299
lws_close_reason(wsi, LWS_CLOSE_STATUS_POLICY_VIOLATION, NULL, 0);
299300
return -1;

0 commit comments

Comments
 (0)