commando: limit to 16 partially-received incoming commands at a time.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-07-21 14:10:48 +09:30 committed by neil saitug
parent 4cada557ba
commit 05a666e424

View file

@ -463,6 +463,10 @@ static void handle_incmd(struct node_id *peer,
incmd->contents = tal_arr(incmd, u8, 0);
tal_arr_expand(&incoming_commands, incmd);
tal_add_destructor2(incmd, destroy_commando, &incoming_commands);
/* More than 16 partial commands at once? Free oldest */
if (tal_count(incoming_commands) > 16)
tal_free(incoming_commands[0]);
}
/* 1MB should be enough for anybody! */