aboutsummaryrefslogtreecommitdiff
path: root/shared/protocol.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-10-28 12:14:50 +0200
committerlonkaars <loek@pipeframe.xyz>2022-10-28 12:14:50 +0200
commit4cd465332087e4ab12709f28fae55df10e1a1154 (patch)
treee00f602321d589acdd6a6f2ae162c5d891902882 /shared/protocol.c
parentf37af779bb836faa7571b7d47036f36f71319aca (diff)
add todo.md, fixed segfault in protocol.c, and fix response sending
Diffstat (limited to 'shared/protocol.c')
-rw-r--r--shared/protocol.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/shared/protocol.c b/shared/protocol.c
index fcc84a4..e17a728 100644
--- a/shared/protocol.c
+++ b/shared/protocol.c
@@ -99,10 +99,11 @@ ws_s_protocol_req_parser_state* ws_protocol_req_parser_alloc() {
void ws_protocol_req_cmd_init(ws_s_protocol_req_parser_state* state) {
state->target = malloc(sizeof(ws_s_protocol_parsed_req_cmd) + sizeof(char*) * state->arg_len);
- for (unsigned int i = 0; i < state->arg_len; i++)
+ unsigned int args = WS_MIN(state->arg_len, WS_PROTOCOL_CMD_MAX_ARGUMENTS);
+ for (unsigned int i = 0; i < args; i++)
state->target->argv[i] = malloc(sizeof(char) * (state->args_len[i] + 1));
- state->target->argc = state->arg_len;
+ state->target->argc = args;
unsigned int head = 0;
for (unsigned int i = 0; i < state->arg_len; i++) {