Commit 33a065a0b7 for openssl.org
commit 33a065a0b787ec41818731453bf3b747a6f51d0e
Author: Bob Beck <beck@openssl.org>
Date: Thu Apr 30 10:34:28 2026 -0600
Don't rely on cmp of uninitialized values in obj_dat.pl
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)
diff --git a/crypto/objects/obj_dat.pl b/crypto/objects/obj_dat.pl
index 12836e1bbd..a2bba8b0fa 100644
--- a/crypto/objects/obj_dat.pl
+++ b/crypto/objects/obj_dat.pl
@@ -219,11 +219,11 @@ printf "static const unsigned int obj_objs[NUM_OBJ] = {\n";
# 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}}};