security: add missing NULL check after calloc in sendspin-recv

Memory Safety: Medium

The ring buffer allocation in the sendspin receiver module was not
checked for NULL. If calloc fails (e.g., due to a large stride value
from network-controlled audio format parameters), the code proceeds
to use the NULL pointer, causing a crash.

Also changed calloc(1, size*stride) to calloc(size, stride) so that
calloc itself checks for multiplication overflow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Wim Taymans 2026-04-28 12:33:52 +02:00
parent e3c20982a8
commit 2fee779161

View file

@ -371,7 +371,9 @@ static int create_stream(struct client *client)
spa_ringbuffer_init(&client->ring); spa_ringbuffer_init(&client->ring);
client->buffer_size = 1024 * 1024; client->buffer_size = 1024 * 1024;
client->buffer = calloc(1, client->buffer_size * client->stride); client->buffer = calloc(client->buffer_size, client->stride);
if (client->buffer == NULL)
return -ENOMEM;
pw_stream_add_listener(client->stream, pw_stream_add_listener(client->stream,
&client->stream_listener, &client->stream_listener,