]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add invalid parameter error to parser generator
authorPauli <ppzgs1@gmail.com>
Thu, 28 Aug 2025 01:49:40 +0000 (11:49 +1000)
committerTomas Mraz <tomas@openssl.org>
Thu, 11 Sep 2025 15:53:23 +0000 (17:53 +0200)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28360)

util/perl/OpenSSL/paramnames.pm

index e6462900ae4eba7258b8af62b7848319a598e0bc..cf5be346eb969fe6a8b576668ebe074359c03927 100644 (file)
@@ -18,6 +18,7 @@ our @EXPORT_OK = qw(generate_public_macros
 
 my $case_sensitive = 1;
 my $need_break = 0;
+my $invalid_param = "invalid param";
 
 my %params = (
 # Well known parameter names that core passes to providers
@@ -680,7 +681,11 @@ sub trie_matched {
   my $indent1 = shift;
   my $indent2 = shift;
 
-  if (defined($num)) {
+  if ($field eq $invalid_param) {
+    printf "%sERR_raise_data(ERR_LIB_PROV, ERR_R_UNSUPPORTED,\n", $indent1;
+    printf "%s               \"param %%s is unsupported\", s);\n", $indent1;
+    printf "%sreturn 0;\n", $indent1;
+  } elsif (defined($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;
@@ -848,6 +853,10 @@ sub output_param_decoder {
 
         $prms{$pname} = $pident;
 
+        if ($pident eq $invalid_param) {
+            # Skip error cases in parameter list
+            next;
+        }
         if (defined $pnum) {
             if ($pnum eq 'hidden') {
                 next;
@@ -878,6 +887,10 @@ sub output_param_decoder {
     printf "struct %s_st {\n", $decoder_name_base;
     my %done_prms = ();
     foreach my $pident (sort values %prms) {
+        if ($pident eq $invalid_param) {
+            # Skip error cases in structure
+            next;
+        }
         if (not defined $done_prms{$pident}) {
             $done_prms{$pident} = 1;
             output_ifdef($ifdefs{$pident});