Since we use this for a sort, in theory this could become
inconsistent if we were to do a make update, re-generate
the output, and check it in from a different development
platform that returns different inconsistencies in how
cmp behaves on uninitialized values.
Rather than ponder this, just make this consistent
by ensuring undefined values have 0 length, and remove
the disabling of the warnings in obj_cmp
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
MergeDate: Thu May 7 15:41:12 2026
(Merged from https://github.com/openssl/openssl/pull/31046)
# Compare DER; prefer shorter; if some length, use the "smaller" encoding.
sub obj_cmp
{
- no warnings "uninitialized";
- my $A = $obj_len{$obj{$nid{$a}}};
- my $B = $obj_len{$obj{$nid{$b}}};
+ my $A = defined($obj_len{$obj{$nid{$a}}}) ? $obj_len{$obj{$nid{$a}}} : 0;
+ my $B = defined($obj_len{$obj{$nid{$b}}}) ? $obj_len{$obj{$nid{$b}}} : 0;
my $r = $A - $B;
return $r if $r != 0;
+ return 0 if $A == 0;
$A = $obj_der{$obj{$nid{$a}}};
$B = $obj_der{$obj{$nid{$b}}};