1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 12:56:37 +02:00

relay/api: process HTTP request received as soon as a NULL char is received

This fixes the API probe made by schemathesis, so it detects immediately that
such NULL byte is not allowed by WeeChat, instead of timing out after 10
seconds:

   API capabilities:

     Supports NULL byte in headers:    ✘
This commit is contained in:
Sébastien Helleu
2025-06-23 23:07:05 +02:00
parent 87e84d9053
commit 58067431de
4 changed files with 16 additions and 8 deletions
+1
View File
@@ -39,6 +39,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
- irc: display nick changes and quit messages when option irc.look.ignore_tag_messages is enabled ([#2241](https://github.com/weechat/weechat/issues/2241))
- perl: fix build when multiplicity is not available ([#2243](https://github.com/weechat/weechat/issues/2243))
- relay/api: reject any invalid or unknown password hash algorithm in handshake resource
- relay/api: process HTTP request received as soon as a NULL char is received
- relay/weechat: fix empty buffers in client when WeeChat is running on Solaris/illumos
- build: fix build on Solaris/illumos (issue #2251)
+4 -3
View File
@@ -504,7 +504,8 @@ relay_client_recv_text_buffer (struct t_relay_client *client,
if ((client->websocket == RELAY_CLIENT_WEBSOCKET_INITIALIZING)
|| (client->recv_data_type == RELAY_CLIENT_DATA_HTTP))
{
relay_http_recv (client, buffer + index);
relay_http_recv (client, buffer + index, length_buffer - index);
break;
}
else
{
@@ -582,7 +583,7 @@ relay_client_read_websocket_frames (struct t_relay_client *client,
if ((client->websocket == RELAY_CLIENT_WEBSOCKET_INITIALIZING)
|| (client->recv_data_type == RELAY_CLIENT_DATA_HTTP))
{
relay_http_recv (client, frames[i].payload);
relay_http_recv (client, frames[i].payload, frames[i].payload_size);
}
else if ((client->recv_data_type == RELAY_CLIENT_DATA_TEXT_LINE)
|| (client->recv_data_type == RELAY_CLIENT_DATA_TEXT_MULTILINE))
@@ -694,7 +695,7 @@ relay_client_recv_buffer (struct t_relay_client *client,
if ((client->websocket == RELAY_CLIENT_WEBSOCKET_INITIALIZING)
|| (client->recv_data_type == RELAY_CLIENT_DATA_HTTP))
{
relay_http_recv (client, buffer);
relay_http_recv (client, buffer, buffer_size);
}
else if ((client->recv_data_type == RELAY_CLIENT_DATA_TEXT_LINE)
|| (client->recv_data_type == RELAY_CLIENT_DATA_TEXT_MULTILINE))
+9 -4
View File
@@ -935,11 +935,13 @@ relay_http_process_request (struct t_relay_client *client)
*/
void
relay_http_recv (struct t_relay_client *client, const char *data)
relay_http_recv (struct t_relay_client *client, const char *data, int size)
{
char *new_partial, *pos;
char *new_partial, *pos, **null_char;
int length, ws_deflate_allowed;
null_char = memchr (data, 0, size);
if (client->partial_message)
{
new_partial = realloc (client->partial_message,
@@ -1003,8 +1005,11 @@ relay_http_recv (struct t_relay_client *client, const char *data)
relay_http_add_to_body (client->http_req, &(client->partial_message));
}
/* process the request if it's ready to be processed (all parsed) */
if (client->http_req->status == RELAY_HTTP_END)
/*
* process the request if it's ready to be processed (all parsed)
* or if we received a NULL char in the HTTP message (forbidden)
* */
if ((client->http_req->status == RELAY_HTTP_END) || null_char)
{
relay_http_process_request (client);
relay_http_request_reinit (client->http_req);
+2 -1
View File
@@ -100,7 +100,8 @@ extern long relay_http_get_param_long (struct t_relay_http_request *request,
extern int relay_http_parse_method_path (struct t_relay_http_request *request,
const char *method_path);
extern int relay_http_check_auth (struct t_relay_client *client);
extern void relay_http_recv (struct t_relay_client *client, const char *data);
extern void relay_http_recv (struct t_relay_client *client,
const char *data, int size);
extern int relay_http_send (struct t_relay_client *client,
int return_code, const char *message,
const char *headers,