security: fix potential buffer over-read in combine-sink name encoding

spa_json_encode_string was called with sizeof(name)-1, which would
not write a null terminator on truncation. Use sizeof(name) and skip
sink names that don't fit in the buffer.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Wim Taymans 2026-04-30 09:27:37 +02:00
parent 912f7f5c64
commit 4a34da368e

View file

@ -185,7 +185,9 @@ static int module_combine_sink_load(struct module *module)
} else {
for (i = 0; data->sink_names[i] != NULL; i++) {
char name[1024];
spa_json_encode_string(name, sizeof(name)-1, data->sink_names[i]);
if (spa_json_encode_string(name, sizeof(name), data->sink_names[i]) >= (int)sizeof(name))
continue;
fprintf(f, " { matches = [ { media.class = \"Audio/Sink\" ");
fprintf(f, " node.name = %s } ]", name);
fprintf(f, " actions = { create-stream = { } } }");