From: slontis Date: Tue, 27 Feb 2024 02:34:49 +0000 (+1100) Subject: Make the generated params_idx.c file deterministic if run multiple X-Git-Tag: openssl-3.3.0-alpha1~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5df34ca70a6edc4c0698a6e98add6450b9ce24ff;p=thirdparty%2Fopenssl.git Make the generated params_idx.c file deterministic if run multiple times. Fixes #23672 There are many name/value pairs currently that have duplicate names e.g. 'CAPABILITY_TLS_GROUP_MAX_TLS' => "tls-max-tls", 'CAPABILITY_TLS_SIGALG_MAX_TLS' => "tls-max-tls", Stripping the .pm file down to just the above entries and running multiple times gives different results for the produce_decoder. On multiple runs any iterations over the unordered hash table keys using foreach my $name (keys %params) results in a different order on multiple runs. Because of this the mapping from the hash 'value' back to the 'key' will be different. Note that the code also uses another mechanism in places that uses "name1" => "value" "name2" => "*name1" Rather than fix all the strings the change done was to sort the keys. If we were to chose to fix the strings then the perl code should be changed to detect duplicates. Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz Reviewed-by: Richard Levitte Reviewed-by: Tom Cosgrove (Merged from https://github.com/openssl/openssl/pull/23688) --- diff --git a/util/perl/OpenSSL/paramnames.pm b/util/perl/OpenSSL/paramnames.pm index df93202d1d8..e7de37bb6a0 100644 --- a/util/perl/OpenSSL/paramnames.pm +++ b/util/perl/OpenSSL/paramnames.pm @@ -563,7 +563,7 @@ sub generate_trie { my $nodes = 0; my $chars = 0; - foreach my $name (keys %params) { + foreach my $name (sort keys %params) { my $val = $params{$name}; if (substr($val, 0, 1) ne '*') { my $cursor = \%trie;