From 2993bf1722280acc13565bc51eff3c06352eb6e9 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 4 May 2026 12:16:26 +0200 Subject: [PATCH] filter-graph: limit lv2 ports Limit the lv2 ports to 512 and check for allocation errors. --- spa/plugins/filter-graph/plugin_lv2.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spa/plugins/filter-graph/plugin_lv2.c b/spa/plugins/filter-graph/plugin_lv2.c index 747b1b7a1..14c8af6d9 100644 --- a/spa/plugins/filter-graph/plugin_lv2.c +++ b/spa/plugins/filter-graph/plugin_lv2.c @@ -5,6 +5,8 @@ #include #include +#define MAX_PORTS 512 + #include #include @@ -536,7 +538,15 @@ static const struct spa_fga_descriptor *lv2_plugin_make_desc(void *plugin, const desc->desc.flags = 0; desc->desc.n_ports = lilv_plugin_get_num_ports(p->p); + if (desc->desc.n_ports > MAX_PORTS) { + free(desc); + return NULL; + } desc->desc.ports = calloc(desc->desc.n_ports, sizeof(struct spa_fga_port)); + if (desc->desc.ports == NULL) { + free(desc); + return NULL; + } mins = alloca(desc->desc.n_ports * sizeof(float)); maxes = alloca(desc->desc.n_ports * sizeof(float));