security: fix OOB read in IEC958 format enum parsing

In the SPA_CHOICE_Enum case, values[index+1] was used to skip the
default value at index 0, but the bounds check only validated index,
not index+1. Move bounds checks into each case with the correct limit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Wim Taymans 2026-04-30 09:19:41 +02:00
parent 390874e7c3
commit e1f4c441f4

View file

@ -750,16 +750,17 @@ static int format_info_iec958_from_param(struct format_info *info, struct spa_po
if (val->type != SPA_TYPE_Id)
return -ENOTSUP;
if (index >= n_values)
return -ENOENT;
values = SPA_POD_BODY(val);
switch (choice) {
case SPA_CHOICE_None:
if (index >= n_values)
return -ENOENT;
info->encoding = format_encoding_from_id(values[index]);
break;
case SPA_CHOICE_Enum:
if (index + 1 >= n_values)
return -ENOENT;
info->encoding = format_encoding_from_id(values[index+1]);
break;
default: