]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
params: produce an error if a parameter is repeated
authorPauli <ppzgs1@gmail.com>
Mon, 4 Aug 2025 01:05:57 +0000 (11:05 +1000)
committerPauli <ppzgs1@gmail.com>
Fri, 8 Aug 2025 00:33:22 +0000 (10:33 +1000)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/28163)

util/perl/OpenSSL/paramnames.pm

index 2418d07577aff81bc8f014e58d64b663375e1d07..003c65fc83199c56e1824df86875c66e0dab3f3f 100644 (file)
@@ -678,8 +678,12 @@ sub trie_matched {
     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;
-    printf "%sr->%s = (OSSL_PARAM *)p;\n", $indent2, $field;
+    printf "%sif (ossl_unlikely(r->%s != NULL)) {\n", $indent1, $field;
+    printf "%sERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,\n", $indent2;
+    printf "%s               \"param %%s is repeated\", s);\n", $indent2;
+    printf "%sreturn 0;\n", $indent2;
+    printf "%s}\n", $indent1;
+    printf "%sr->%s = (OSSL_PARAM *)p;\n", $indent1, $field;
   }
 }
 
@@ -727,7 +731,7 @@ sub generate_decoder_from_trie {
             printf "%scase '\\0':\n", $indent0;
             trie_matched($field, $num, $indent1, $indent2);
             output_endifdef($ifdefs->{$field});
-       } else {
+        } else {
             printf "%sbreak;\n", $indent1;
             printf "%scase '%s':", $indent0, $l;
             if (not $case_sensitive) {