params: emit an error if a parameter array overflows

This is in addition to returning an error code.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27923)
This commit is contained in:
Pauli 2025-07-17 11:13:56 +10:00 committed by Tomas Mraz
parent 454119a625
commit 39868ab1bf
1 changed files with 4 additions and 1 deletions

View File

@ -653,8 +653,11 @@ sub trie_matched {
my $indent2 = shift;
if (defined($num)) {
printf "%sif (ossl_unlikely(r->num_%s >= %s))\n", $indent1, $field, $num;
printf "%sif (ossl_unlikely(r->num_%s >= %s)) {\n", $indent1, $field, $num;
printf "%sERR_raise_data(ERR_LIB_PROV, PROV_R_TOO_MANY_RECORDS,\n", $indent2;
printf "%s \"param %%s present >%%d times\", s, $num);\n", $indent2;
printf "%sreturn 0;\n", $indent2;
printf "%s}\n", $indent1;
printf "%sr->%s[r->num_%s++] = (OSSL_PARAM *)p;\n", $indent1, $field, $field;
} else {
printf "%sif (ossl_likely(r->%s == NULL))\n", $indent1, $field;