azrp: fix a cmdgen bug causing crashes when buffer is full

Command finalization could refuse to finalize commands that were
allocated, because its rounding method added 4 extra bytes to commands
whose size is a multiple of 4. Such commands would still be instantiated
but without commands_length advancing, causing the underlying memory to
be reallocated later, leading to overlapping commands.
This commit is contained in:
Lephenixnoir 2023-07-17 23:00:15 +02:00
parent 99c89e5628
commit e26a96364c
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 1 additions and 1 deletions

View File

@ -300,7 +300,7 @@ void *azrp_alloc_command(size_t size, int *extra, int count)
void azrp_finalize_command(void const *command, int total_size)
{
(void)command;
total_size = (total_size | 3) + 1;
total_size = (total_size + 3) & -4;
if(commands_length + total_size > (int)sizeof commands_data)
return;