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 <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23688)
This commit is contained in:
slontis 2024-02-27 13:34:49 +11:00 committed by Matt Caswell
parent 854539889d
commit 5df34ca70a

View File

@ -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;