summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-04-07 17:12:06 +0200
committerSébastien Helleu <flashcode@flashtux.org>2024-04-07 17:22:03 +0200
commitec8c4cc0423651bb010634724868836a498391c2 (patch)
tree627e5afb4467d6248ac51d6ce8a0cb779aff0c54 /src
parent86dea12b71825af11d821526cd1a8b83e9a06fc8 (diff)
downloadweechat-ec8c4cc0423651bb010634724868836a498391c2.zip
relay/api: use function asprintf to build key and check websocket reply
Diffstat (limited to 'src')
-rw-r--r--src/plugins/relay/api/remote/relay-remote-network.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/plugins/relay/api/remote/relay-remote-network.c b/src/plugins/relay/api/remote/relay-remote-network.c
index 7832c7b6c..c374873fd 100644
--- a/src/plugins/relay/api/remote/relay-remote-network.c
+++ b/src/plugins/relay/api/remote/relay-remote-network.c
@@ -136,7 +136,7 @@ relay_remote_network_check_auth (struct t_relay_remote *remote,
cJSON *json_body, *json_error;
const char *msg_error, *msg_resp_error, *ptr_ws_accept;
char *key, hash[160 / 8], sec_websocket_accept[128];
- int length, accept_ok, hash_size;
+ int accept_ok, hash_size;
http_resp = NULL;
msg_error = NULL;
@@ -177,12 +177,9 @@ relay_remote_network_check_auth (struct t_relay_remote *remote,
"sec-websocket-accept");
if (ptr_ws_accept)
{
- length = strlen (remote->websocket_key) + strlen (WEBSOCKET_GUID) + 1;
- key = malloc (length);
- if (key)
+ if (weechat_asprintf (&key, "%s%s", remote->websocket_key,
+ WEBSOCKET_GUID) >= 0)
{
- snprintf (key, length,
- "%s%s", remote->websocket_key, WEBSOCKET_GUID);
if (weechat_crypto_hash (key, strlen (key), "sha1",
hash, &hash_size))
{