Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

oid_registry: allow arbitrary size OIDs

The current OID registry parser uses 64 bit arithmetic which limits us to
supporting 64 bit or smaller OIDs. This isn't usually a problem except
that it prevents us from representing the 2.25. prefix OIDs which are the
OID representation of UUIDs and have a 128 bit number following the
prefix. Rather than import not often used perl arithmetic modules,
replace the current perl 64 bit arithmetic with a callout to bc, which is
arbitrary precision, for decimal to base 2 conversion, then do pure string
operations on the base 2 number.

[James.Bottomley@HansenPartnership.com: tidy up perl with better my placement also set bc to arbitrary size]
Link: https://lkml.kernel.org/r/dbc90c344c691ed988640a28367ff895b5ef2604.camel@HansenPartnership.com
Link: https://lkml.kernel.org/r/833c858cd74533203b43180208734b84f1137af0.camel@HansenPartnership.com
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Blaise Boscaccy <bboscaccy@linux.microsoft.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

James Bottomley and committed by
Andrew Morton
03192270 6c790212

+18 -8
+18 -8
lib/build_OID_registry
··· 60 60 # Determine the encoded length of this OID 61 61 my $size = $#components; 62 62 for (my $loop = 2; $loop <= $#components; $loop++) { 63 - my $c = $components[$loop]; 63 + $ENV{'BC_LINE_LENGTH'} = "0"; 64 + my $c = `echo "ibase=10; obase=2; $components[$loop]" | bc`; 65 + chomp($c); 64 66 65 67 # We will base128 encode the number 66 - my $tmp = ($c == 0) ? 0 : int(log($c)/log(2)); 68 + my $tmp = length($c) - 1; 67 69 $tmp = int($tmp / 7); 68 70 $size += $tmp; 69 71 } ··· 102 100 push @octets, $components[0] * 40 + $components[1]; 103 101 104 102 for (my $loop = 2; $loop <= $#components; $loop++) { 105 - my $c = $components[$loop]; 103 + # get the base 2 representation of the component 104 + $ENV{'BC_LINE_LENGTH'} = "0"; 105 + my $c = `echo "ibase=10; obase=2; $components[$loop]" | bc`; 106 + chomp($c); 106 107 107 - # Base128 encode the number 108 - my $tmp = ($c == 0) ? 0 : int(log($c)/log(2)); 108 + my $tmp = length($c) - 1; 109 109 $tmp = int($tmp / 7); 110 110 111 - for (; $tmp > 0; $tmp--) { 112 - push @octets, (($c >> $tmp * 7) & 0x7f) | 0x80; 111 + # zero pad upto length multiple of 7 112 + $c = substr("0000000", 0, ($tmp + 1) * 7 - length($c)).$c; 113 + 114 + # Base128 encode the number 115 + for (my $j = 0; $j < $tmp; $j++) { 116 + my $b = oct("0b".substr($c, $j * 7, 7)); 117 + 118 + push @octets, $b | 0x80; 113 119 } 114 - push @octets, $c & 0x7f; 120 + push @octets, oct("0b".substr($c, $tmp * 7, 7)); 115 121 } 116 122 117 123 push @encoded_oids, \@octets;