1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-07 10:13:12 +02:00

relay/api: return an error 401 when header "x-weechat-totp" has an invalid value

This commit is contained in:
Sébastien Helleu
2025-10-26 09:19:43 +01:00
parent e637e0de1c
commit 0009732f78
3 changed files with 22 additions and 3 deletions
+13 -3
View File
@@ -588,9 +588,9 @@ relay_http_get_auth_status (struct t_relay_client *client)
{
const char *auth, *sec_websocket_protocol, *client_totp, *pos;
char *relay_password, *totp_secret, *info_totp_args, *info_totp;
char *user_pass;
char **protocol_array;
char *user_pass, **protocol_array, *error;
int rc, i, length, protocol_count, use_base64url, totp_ok;
long number;
rc = 0;
relay_password = NULL;
@@ -599,6 +599,17 @@ relay_http_get_auth_status (struct t_relay_client *client)
user_pass = NULL;
use_base64url = 0;
client_totp = weechat_hashtable_get (client->http_req->headers, "x-weechat-totp");
if (client_totp && client_totp[0])
{
number = strtol (client_totp, &error, 10);
if (!error || error[0] || (number < 0) || (number > 999999))
{
rc = -4;
goto end;
}
}
relay_password = weechat_string_eval_expression (
weechat_config_string (relay_config_network_password),
NULL, NULL, NULL);
@@ -725,7 +736,6 @@ relay_http_get_auth_status (struct t_relay_client *client)
NULL, NULL, NULL);
if (totp_secret && totp_secret[0])
{
client_totp = weechat_hashtable_get (client->http_req->headers, "x-weechat-totp");
if (!client_totp || !client_totp[0])
{
rc = -3;