server: Return error when hardware message is too large.

So that the client allocates a larger receive buffer when needed and not
trigger the assert below when setting the reply message data.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2022-01-12 17:23:59 +01:00 committed by Alexandre Julliard
parent d416f1c4ce
commit 095204a9f3
1 changed files with 8 additions and 0 deletions

View File

@ -2145,6 +2145,14 @@ static int get_hardware_message( struct thread *thread, unsigned int hw_id, user
clear_bits &= ~get_hardware_msg_bit( msg ); clear_bits &= ~get_hardware_msg_bit( msg );
continue; continue;
} }
reply->total = msg->data_size;
if (msg->data_size > get_reply_max_size())
{
set_error( STATUS_BUFFER_OVERFLOW );
return 1;
}
/* now we can return it */ /* now we can return it */
if (!msg->unique_id) msg->unique_id = get_unique_id(); if (!msg->unique_id) msg->unique_id = get_unique_id();
reply->type = MSG_HARDWARE; reply->type = MSG_HARDWARE;