ASN1/_decode.pm

filter: Statementstmt 82.2% 237 / 288 Branchbran 67.3% 163 / 242 Conditioncond 52.0% 52 / 100 MC/DCmcdc 29.5% 18 / 61 Subroutinesub 91.3% 21 / 23 Podpod n/a totaltotal 68.7% 491 / 714 CC 164 SCAR 49.1
CC
164
Cov
72%
_decode
256.8
_dec_set
175.1
_scan_indef
15.1
CRAP 135.3
↑ Summary ASN1/Debug.pm »
1 # Copyright (c) 2000-2005 Graham Barr <gbarr@pobox.com>. All rights reserved.
2 # This program is free software; you can redistribute it and/or
3 # modify it under the same terms as Perl itself.
4  
5 package Convert::ASN1;
6 24 $Convert::ASN1::VERSION = '0.36';
7 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 24 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 24 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.1
11 24 local $SIG{__DIE__};
12 24 ▶ eval { require bytes and 'bytes'->import };
Branch: 1 branch
BranchTrueFalseTotal
require bytes and "bytes"->import 24 0 24
13 }
14  
15 # These are the subs that do the decode, they are called with
16 # 0 1 2 3 4
17 # $optn, $op, $stash, $var, $buf
18 # The order must be the same as the op definitions above
19  
20 my @decode = (
21 0 ▶ sub { die "internal error\n" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 24 \&_dec_boolean,
23 \&_dec_integer,
24 \&_dec_bitstring,
25 \&_dec_string,
26 \&_dec_null,
27 \&_dec_object_id,
28 \&_dec_real,
29 \&_dec_sequence,
30 \&_dec_explicit,
31 \&_dec_set,
32 \&_dec_time,
33 \&_dec_time,
34 \&_dec_utf8,
35 undef, # ANY
36 undef, # CHOICE
37 \&_dec_object_id,
38 \&_dec_bcd,
39 );
40  
41 24 my @ctr;
42 24 @ctr[opBITSTR, opSTRING, opUTF8] = (\&_ctr_bitstring,\&_ctr_string,\&_ctr_string);
43  
44  
45 566 ▶sub _decode {
Subroutine _decode: called CC=72 SCAR=55.5
46 566 my ($optn, $ops, $stash, $pos, $end, $seqof, $larr) = @_;
47 566 my $idx = 0;
48  
49 # we try not to copy the input buffer at any time
50 566 foreach my $buf ($_[-1]) {
51 OP:
52 566 foreach my $op (@{$ops}) {
53 1038 my $var = $op->[cVAR];
54  
55 1038 ▶ if (length $op->[cTAG]) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $op->[0]) { } 794 244 1038
56  
57 TAGLOOP: {
58 794 my($tag,$len,$npos,$indef) = _decode_tl($buf,$pos,$end,$larr)
59 913 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
() = _decode_tl($buf, $pos, $end, $larr) or do { next OP if $pos == $end and $seqof || defined $op->[5]; die "decode error" } 888 25 913
60 25 ▶ next OP if $pos==$end and ($seqof || defined $op->[cEXT]);
Branch: 1 branch
BranchTrueFalseTotal
if $pos == $end and $seqof || defined $op->[5] 23 2 25
Condition50%3/6
$pos == $end and $seqof || defined $op->[5]
!ll&&!rl&&r
2023
$seqof or defined $op->[5]
l!l&&r!l&&!r
0230
MC/DC33%1/3
$pos == $end and $seqof || defined $op->[5]
$pos == $end $seqof defined $op->[5]
Truth table50%2/4
A and B or C
A= $pos == $endB= $seqofC= defined $op->[5]
ABCresult
0XX0
1000
11X1
1011
61 2 die "decode error";
62 };
63  
64 888 ▶ if ($tag eq $op->[cTAG]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag eq $op->[0]) 822 66 888
65  
66 822 &{$decode[$op->[cTYPE]]}(
67 $optn,
68 $op,
69 $stash,
70 # We send 1 if there is not var as if there is the decode
71 # should be getting undef. So if it does not get undef
72 # it knows it has no variable
73 822 ▶ ($seqof ? $seqof->[$idx++] : defined($var) ? $stash->{$var} : ref($stash) eq 'SCALAR' ? $$stash : 1),
Branch: 3 branches
BranchTrueFalseTotal
$seqof ? : 240 582 822
defined $var ? : 498 84 582
ref $stash eq 'SCALAR' ? : 16 68 84
74 $buf,$npos,$len, $larr
75 );
76  
77 822 $pos = $npos+$len+$indef;
78  
79 822 ▶ redo TAGLOOP if $seqof && $pos < $end;
Branch: 1 branch
BranchTrueFalseTotal
if $seqof and $pos < $end 119 703 822
Condition100%3/3
$seqof and $pos < $end
!ll&&!rl&&r
582121119
MC/DC100%2/2
$seqof and $pos < $end
$seqof $pos < $end
Truth table100%3/3
A and B
A= $seqofB= $pos < $end
ABresult
0X0
100
111
80 703 next OP;
81 }
82  
83 66 ▶ if ($tag eq ($op->[cTAG] | pack("C",ASN_CONSTRUCTOR))
Branch: 1 branch
BranchTrueFalseTotal
if ($tag eq ($op->[0] | " ") and my $ctr = $ctr[$op->[1]]) 1 65 66
Condition66%2/3
$tag eq ($op->[0] | " ") and my $ctr = $ctr[$op->[1]]
!ll&&!rl&&r
6501
MC/DC50%1/2
$tag eq ($op->[0] | " ") and my $ctr = $ctr[$op->[1]]
$tag eq ($op->[0] | " ") my $ctr = $ctr[$op->[1]]
Truth table66%2/3
A and B
A= $tag eq ($op->[0] | " ")B= my $ctr = $ctr[$op->[1]]
ABresult
0X0
100
111
84 and my $ctr = $ctr[$op->[cTYPE]])
85 {
86 1 _decode(
87 $optn,
88 [$op],
89 undef,
90 $npos,
91 $npos+$len,
92 (\my @ctrlist),
93 $larr,
94 $buf,
95 );
96  
97 ($seqof
98 ? $seqof->[$idx++] # = &{$ctr}(@ctrlist);
99 : defined($var)
100 ? $stash->{$var} # = &{$ctr}(@ctrlist);
101 : ref($stash) eq 'SCALAR'
102 ? $$stash # = &{$ctr}(@ctrlist);
103 : my $any ) # = &{$ctr}(@ctrlist) FIX #43
104 1 ▶ = &{$ctr}(@ctrlist);
Branch: 3 branches
BranchTrueFalseTotal
$seqof ? : 0 1 1
defined $var ? : 1 0 1
ref $stash eq 'SCALAR' ? : 0 0 0
105  
106 1 $pos = $npos+$len+$indef;
107  
108 1 ▶ redo TAGLOOP if $seqof && $pos < $end;
Branch: 1 branch
BranchTrueFalseTotal
if $seqof and $pos < $end 0 1 1
Condition33%1/3
$seqof and $pos < $end
!ll&&!rl&&r
100
MC/DC0%0/2
$seqof and $pos < $end
$seqof $pos < $end
Truth table33%1/3
A and B
A= $seqofB= $pos < $end
ABresult
0X0
100
111
109 1 next OP;
110  
111 }
112  
113 65 ▶ if ($seqof || defined $op->[cEXT]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($seqof or defined $op->[5]) 65 0 65
Condition33%1/3
$seqof or defined $op->[5]
l!l&&r!l&&!r
0650
MC/DC0%0/2
$seqof or defined $op->[5]
$seqof defined $op->[5]
Truth table33%1/3
A or B
A= $seqofB= defined $op->[5]
ABresult
1X1
011
000
114 65 next OP;
115 }
116  
117 0 ▶ die "decode error " . unpack("H*",$tag) ."<=>" . unpack("H*",$op->[cTAG]), " ",$pos," ",$op->[cTYPE]," ",$op->[cVAR]||'';
Condition0%0/2
$op->[2] || ''
l!l
00
MC/DC0%0/1
$op->[2] || ''
$op->[2]
Truth table0%0/2
A
A= $op->[2]
Aresult
11
00
118 }
119 }
120 else { # opTag length is zero, so it must be an ANY, CHOICE or EXTENSIONS
121
122 244 ▶ if ($op->[cTYPE] == opANY) {
Branch: 3 branches
BranchTrueFalseTotal
if ($op->[1] == 14) { } 83 161 244
elsif ($op->[1] == 15) { } 157 4 161
elsif ($op->[1] == 18) { } 4 0 4
123  
124 ANYLOOP: {
125  
126 83 my($tag,$len,$npos,$indef) = _decode_tl($buf,$pos,$end,$larr)
127 84 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
() = _decode_tl($buf, $pos, $end, $larr) or do { next OP if $pos == $end and $seqof || defined $op->[5]; die "decode error" } 82 2 84
128 2 ▶ next OP if $pos==$end and ($seqof || defined $op->[cEXT]);
Branch: 1 branch
BranchTrueFalseTotal
if $pos == $end and $seqof || defined $op->[5] 2 0 2
Condition33%2/6
$pos == $end and $seqof || defined $op->[5]
!ll&&!rl&&r
002
$seqof or defined $op->[5]
l!l&&r!l&&!r
020
MC/DC0%0/3
$pos == $end and $seqof || defined $op->[5]
$pos == $end $seqof defined $op->[5]
Truth table25%1/4
A and B or C
A= $pos == $endB= $seqofC= defined $op->[5]
ABCresult
0XX0
1000
11X1
1011
129 0 die "decode error";
130 };
131  
132 82 $len += $npos - $pos + $indef;
133  
134 82 my $handler;
135 82 ▶ if ($op->[cDEFINE]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->[7]) 2 80 82
136 2 ▶ $handler = $optn->{oidtable} && $optn->{oidtable}{$stash->{$op->[cDEFINE]}};
Condition33%1/3
$optn->{'oidtable'} && $optn->{'oidtable'}{$$stash{$op->[7]}}
!ll&&!rl&&r
002
MC/DC0%0/2
$optn->{'oidtable'} && $optn->{'oidtable'}{$$stash{$op->[7]}}
$optn->{'oidtable'} $optn->{'oidtable'}{$$stash{$op->[7]}}
Truth table33%1/3
A && B
A= $optn->{'oidtable'}B= $optn->{'oidtable'}{$$stash{$op->[7]}}
ABresult
0X0
100
111
137 2 ▶ $handler ||= $optn->{handlers}{$op->[cVAR]}{$stash->{$op->[cDEFINE]}};
Condition33%1/3
$handler ||= $optn->{"handlers"}{$op->[2]}{$$stash{$op->[7]}}
l!l&&r!l&&!r
200
MC/DC0%0/2
$handler ||= $optn->{"handlers"}{$op->[2]}{$$stash{$op->[7]}}
$handler $optn->{"handlers"}{$op->[2]}{$$stash{$op->[7]}}
Truth table33%1/3
A ||= B
A= $handlerB= $optn->{"handlers"}{$op->[2]}{$$stash{$op->[7]}}
ABresult
1X1
011
000
138 }
139  
140 82 ▶ ($seqof ? $seqof->[$idx++] : ref($stash) eq 'SCALAR' ? $$stash : $stash->{$var})
Branch: 3 branches
BranchTrueFalseTotal
$handler ? : 2 80 82
$seqof ? : 2 80 82
ref $stash eq 'SCALAR' ? : 1 79 80
141 = $handler ? $handler->decode(substr($buf,$pos,$len)) : substr($buf,$pos,$len);
142  
143 82 $pos += $len;
144  
145 82 ▶ redo ANYLOOP if $seqof && $pos < $end;
Branch: 1 branch
BranchTrueFalseTotal
if $seqof and $pos < $end 1 81 82
Condition100%3/3
$seqof and $pos < $end
!ll&&!rl&&r
8011
MC/DC100%2/2
$seqof and $pos < $end
$seqof $pos < $end
Truth table100%3/3
A and B
A= $seqofB= $pos < $end
ABresult
0X0
100
111
146 }
147 }
148 elsif ($op->[cTYPE] == opCHOICE) {
149  
150 CHOICELOOP: {
151 157 my($tag,$len,$npos,$indef) = _decode_tl($buf,$pos,$end,$larr)
152 160 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
() = _decode_tl($buf, $pos, $end, $larr) or do { next OP if $pos == $end and $seqof || defined $op->[5]; die "decode error" } 160 0 160
153 0 ▶ next OP if $pos==$end and ($seqof || defined $op->[cEXT]);
Branch: 1 branch
BranchTrueFalseTotal
if $pos == $end and $seqof || defined $op->[5] 0 0 0
Condition0%0/6
$pos == $end and $seqof || defined $op->[5]
!ll&&!rl&&r
000
$seqof or defined $op->[5]
l!l&&r!l&&!r
000
MC/DC0%0/3
$pos == $end and $seqof || defined $op->[5]
$pos == $end $seqof defined $op->[5]
Truth table0%0/4
A and B or C
A= $pos == $endB= $seqofC= defined $op->[5]
ABCresult
0XX0
1000
11X1
1011
154 0 die "decode error";
155 };
156 160 my $extensions;
157 160 foreach my $cop (@{$op->[cCHILD]}) {
158  
159 301 ▶ if ($tag eq $cop->[cTAG]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag eq $cop->[0]) 157 144 301
160  
161 my $nstash = $seqof
162 ? ($seqof->[$idx++]={})
163 : defined($var)
164 157 ▶ ? ($stash->{$var}={})
Branch: 3 branches
BranchTrueFalseTotal
$seqof ? : 8 149 157
defined $var ? : 137 12 149
ref $stash eq 'SCALAR' ? : 5 7 12
165 : ref($stash) eq 'SCALAR'
166 ? ($$stash={}) : $stash;
167  
168 157 &{$decode[$cop->[cTYPE]]}(
169 $optn,
170 $cop,
171 $nstash,
172 157 ▶ ($cop->[cVAR] ? $nstash->{$cop->[cVAR]} : undef),
Branch: 1 branch
BranchTrueFalseTotal
$cop->[2] ? : 157 0 157
173 $buf,$npos,$len,$larr,
174 );
175  
176 157 $pos = $npos+$len+$indef;
177  
178 157 ▶ redo CHOICELOOP if $seqof && $pos < $end;
Branch: 1 branch
BranchTrueFalseTotal
if $seqof and $pos < $end 2 155 157
Condition100%3/3
$seqof and $pos < $end
!ll&&!rl&&r
14962
MC/DC100%2/2
$seqof and $pos < $end
$seqof $pos < $end
Truth table100%3/3
A and B
A= $seqofB= $pos < $end
ABresult
0X0
100
111
179 155 next OP;
180 }
181  
182 144 ▶ if ($cop->[cTYPE] == opEXTENSIONS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cop->[1] == 18) 2 142 144
183 2 $extensions = 1;
184 2 next;
185 }
186  
187 142 ▶ unless (length $cop->[cTAG]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (length $cop->[0]) 2 140 142
188 2 ▶ eval {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { _decode($optn, [$cop], \my %tmp_stash, $pos, $npos + $len + $indef, undef, $larr, $buf); my $nstash = $seqof ? $$seqof[$idx++] = {} : (defined $var ? $stash->{$var} = {} : (ref $stash eq "SCALAR" ? $$stash = {} : $stash)); @{$nstash;}{keys %tmp_stash} = values %tmp_stash } } or next 2 0 2
189 2 _decode(
190 $optn,
191 [$cop],
192 (\my %tmp_stash),
193 $pos,
194 $npos+$len+$indef,
195 undef,
196 $larr,
197 $buf,
198 );
199  
200 my $nstash = $seqof
201 ? ($seqof->[$idx++]={})
202 : defined($var)
203 2 ▶ ? ($stash->{$var}={})
Branch: 3 branches
BranchTrueFalseTotal
$seqof ? : 2 0 2
defined $var ? : 0 0 0
ref $stash eq 'SCALAR' ? : 0 0 0
204 : ref($stash) eq 'SCALAR'
205 ? ($$stash={}) : $stash;
206  
207 2 @{$nstash}{keys %tmp_stash} = values %tmp_stash;
208  
209 } or next;
210  
211 2 $pos = $npos+$len+$indef;
212  
213 2 ▶ redo CHOICELOOP if $seqof && $pos < $end;
Branch: 1 branch
BranchTrueFalseTotal
if $seqof and $pos < $end 1 1 2
Condition66%2/3
$seqof and $pos < $end
!ll&&!rl&&r
011
MC/DC50%1/2
$seqof and $pos < $end
$seqof $pos < $end
Truth table66%2/3
A and B
A= $seqofB= $pos < $end
ABresult
0X0
100
111
214 1 next OP;
215 }
216  
217 140 ▶ if ($tag eq ($cop->[cTAG] | pack("C",ASN_CONSTRUCTOR))
Branch: 1 branch
BranchTrueFalseTotal
if ($tag eq ($cop->[0] | " ") and my $ctr = $ctr[$cop->[1]]) 0 140 140
Condition33%1/3
$tag eq ($cop->[0] | " ") and my $ctr = $ctr[$cop->[1]]
!ll&&!rl&&r
14000
MC/DC0%0/2
$tag eq ($cop->[0] | " ") and my $ctr = $ctr[$cop->[1]]
$tag eq ($cop->[0] | " ") my $ctr = $ctr[$cop->[1]]
Truth table33%1/3
A and B
A= $tag eq ($cop->[0] | " ")B= my $ctr = $ctr[$cop->[1]]
ABresult
0X0
100
111
218 and my $ctr = $ctr[$cop->[cTYPE]])
219 {
220 my $nstash = $seqof
221 ? ($seqof->[$idx++]={})
222 : defined($var)
223 0 ▶ ? ($stash->{$var}={})
Branch: 3 branches
BranchTrueFalseTotal
$seqof ? : 0 0 0
defined $var ? : 0 0 0
ref $stash eq 'SCALAR' ? : 0 0 0
224 : ref($stash) eq 'SCALAR'
225 ? ($$stash={}) : $stash;
226  
227 0 _decode(
228 $optn,
229 [$cop],
230 undef,
231 $npos,
232 $npos+$len,
233 (\my @ctrlist),
234 $larr,
235 $buf,
236 );
237  
238 0 $nstash->{$cop->[cVAR]} = &{$ctr}(@ctrlist);
239 0 $pos = $npos+$len+$indef;
240  
241 0 ▶ redo CHOICELOOP if $seqof && $pos < $end;
Branch: 1 branch
BranchTrueFalseTotal
if $seqof and $pos < $end 0 0 0
Condition0%0/3
$seqof and $pos < $end
!ll&&!rl&&r
000
MC/DC0%0/2
$seqof and $pos < $end
$seqof $pos < $end
Truth table0%0/3
A and B
A= $seqofB= $pos < $end
ABresult
0X0
100
111
242 0 next OP;
243 }
244 }
245  
246 1 ▶ if ($pos < $end && $extensions) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos < $end and $extensions) 1 0 1
Condition33%1/3
$pos < $end and $extensions
!ll&&!rl&&r
001
MC/DC0%0/2
$pos < $end and $extensions
$pos < $end $extensions
Truth table33%1/3
A and B
A= $pos < $endB= $extensions
ABresult
0X0
100
111
247 1 $pos = $npos+$len+$indef;
248  
249 1 ▶ redo CHOICELOOP if $seqof && $pos < $end;
Branch: 1 branch
BranchTrueFalseTotal
if $seqof and $pos < $end 0 1 1
Condition33%1/3
$seqof and $pos < $end
!ll&&!rl&&r
100
MC/DC0%0/2
$seqof and $pos < $end
$seqof $pos < $end
Truth table33%1/3
A and B
A= $seqofB= $pos < $end
ABresult
0X0
100
111
250 1 next OP;
251 }
252 }
253 0 ▶ die "decode error" unless $op->[cEXT];
Branch: 1 branch
BranchTrueFalseTotal
unless $op->[5] 0 0 0
254 }
255 elsif ($op->[cTYPE] == opEXTENSIONS) {
256 4 $pos = $end; # Skip over the rest
257 }
258 else {
259 0 die "this point should never be reached";
260 }
261 }
262 }
263 }
264 564 ▶ die "decode error $pos $end" unless $pos == $end;
Branch: 1 branch
BranchTrueFalseTotal
unless $pos == $end 1 563 564
265 }
266  
267  
268 26 ▶sub _dec_boolean {
Subroutine _dec_boolean: called CC=2 SCAR=6.9
269 # 0 1 2 3 4 5 6
270 # $optn, $op, $stash, $var, $buf, $pos, $len
271  
272 26 ▶ $_[3] = unpack("C",substr($_[4],$_[5],1)) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
unpack('C', substr($_[4], $_[5], 1)) ? : 10 16 26
273 26 1;
274 }
275  
276  
277 109 ▶sub _dec_integer {
Subroutine _dec_integer: called CC=4 SCAR=13.9
278 # 0 1 2 3 4 5 6
279 # $optn, $op, $stash, $var, $buf, $pos, $len
280  
281 109 my $buf = substr($_[4],$_[5],$_[6]);
282 109 ▶ my $tmp = unpack("C",$buf) & 0x80 ? pack("C",255) : pack("C",0);
Branch: 1 branch
BranchTrueFalseTotal
unpack('C', $buf) & 128 ? : 16 93 109
283 109 ▶ if ($_[6] > 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[6] > 4) { } 16 93 109
284 16 ▶ $_[3] = os2ip($buf, $_[0]->{decode_bigint} || 'Math::BigInt');
Condition100%2/2
$_[0]{'decode_bigint'} || 'Math::BigInt'
l!l
115
MC/DC100%1/1
$_[0]{'decode_bigint'} || 'Math::BigInt'
$_[0]{'decode_bigint'}
Truth table100%2/2
A
A= $_[0]{'decode_bigint'}
Aresult
11
00
285 } else {
286 # N unpacks an unsigned value
287 93 $_[3] = unpack("l",pack("l",unpack("N", $tmp x (4-$_[6]) . $buf)));
288 }
289 109 1;
290 }
291  
292  
293 32 ▶sub _dec_bitstring {
Subroutine _dec_bitstring: called CC=1 SCAR=0.0
294 # 0 1 2 3 4 5 6
295 # $optn, $op, $stash, $var, $buf, $pos, $len
296  
297 32 $_[3] = [ substr($_[4],$_[5]+1,$_[6]-1), ($_[6]-1)*8-unpack("C",substr($_[4],$_[5],1)) ];
298 32 1;
299 }
300  
301  
302 187 ▶sub _dec_string {
Subroutine _dec_string: called CC=1 SCAR=0.0
303 # 0 1 2 3 4 5 6
304 # $optn, $op, $stash, $var, $buf, $pos, $len
305  
306 187 $_[3] = substr($_[4],$_[5],$_[6]);
307 187 1;
308 }
309  
310  
311 2 ▶sub _dec_null {
Subroutine _dec_null: called CC=2 SCAR=7.2
312 # 0 1 2 3 4 5 6
313 # $optn, $op, $stash, $var, $buf, $pos, $len
314  
315 2 ▶ $_[3] = exists($_[0]->{decode_null}) ? $_[0]->{decode_null} : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $_[0]{'decode_null'} ? : 0 2 2
316 2 1;
317 }
318  
319  
320 162 ▶sub _dec_object_id {
Subroutine _dec_object_id: called CC=5 SCAR=16.1
321 # 0 1 2 3 4 5 6
322 # $optn, $op, $stash, $var, $buf, $pos, $len
323  
324 162 my @data = unpack("w*",substr($_[4],$_[5],$_[6]));
325 162 ▶ if ($_[1]->[cTYPE] == opOBJID and @data > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1][1] == 6 and @data > 1) 159 3 162
Condition66%2/3
$_[1][1] == 6 and @data > 1
!ll&&!rl&&r
30159
MC/DC50%1/2
$_[1][1] == 6 and @data > 1
$_[1][1] == 6 @data > 1
Truth table66%2/3
A and B
A= $_[1][1] == 6B= @data > 1
ABresult
0X0
100
111
326 159 ▶ if ($data[0] < 40) {
Branch: 2 branches
BranchTrueFalseTotal
if ($data[0] < 40) { } 4 155 159
elsif ($data[0] < 80) { } 36 119 155
327 4 splice(@data, 0, 1, 0, $data[0]);
328 }
329 elsif ($data[0] < 80) {
330 36 splice(@data, 0, 1, 1, $data[0] - 40);
331 }
332 else {
333 119 splice(@data, 0, 1, 2, $data[0] - 80);
334 }
335 }
336 162 $_[3] = join(".", @data);
337 162 1;
338 }
339  
340  
341 24 my @_dec_real_base = (2,8,16);
342  
343 7 ▶sub _dec_real {
Subroutine _dec_real: called CC=10 SCAR=24.5
344 # 0 1 2 3 4 5 6
345 # $optn, $op, $stash, $var, $buf, $pos, $len
346  
347 7 ▶ $_[3] = 0.0, return unless $_[6];
Branch: 1 branch
BranchTrueFalseTotal
unless $_[6] 1 6 7
348  
349 6 my $first = unpack("C",substr($_[4],$_[5],1));
350 6 ▶ if ($first & 0x80) {
Branch: 3 branches
BranchTrueFalseTotal
if ($first & 128) { } 4 2 6
elsif ($first & 64) { } 2 0 2
elsif (substr($_[4], $_[5], $_[6]) =~ /^.([-+]?)0*(\d+(?:\.\d+(?:[Ee][-+]?\d+)?)?)$/s) { } 0 0 0
351 # A real number
352  
353 4 require POSIX;
354  
355 4 my $exp;
356 4 my $expLen = $first & 0x3;
357 4 my $estart = $_[5]+1;
358  
359 4 ▶ if($expLen == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expLen == 3) { } 0 4 4
360 0 $estart++;
361 0 $expLen = unpack("C",substr($_[4],$_[5]+1,1));
362 }
363 else {
364 4 $expLen++;
365 }
366 4 _dec_integer(undef, undef, undef, $exp, $_[4],$estart,$expLen);
367  
368 4 my $mant = 0.0;
369 4 for (reverse unpack("C*",substr($_[4],$estart+$expLen,$_[6]-1-$expLen))) {
370 5 $exp +=8, $mant = (($mant+$_) / 256) ;
371 }
372  
373 4 $mant *= 1 << (($first >> 2) & 0x3);
374 4 ▶ $mant = - $mant if $first & 0x40;
Branch: 1 branch
BranchTrueFalseTotal
if $first & 64 1 3 4
375  
376 4 $_[3] = $mant * POSIX::pow($_dec_real_base[($first >> 4) & 0x3], $exp);
377 4 return;
378 }
379 elsif($first & 0x40) {
380 2 ▶ $_[3] = POSIX::HUGE_VAL(),return if $first == 0x40;
Branch: 1 branch
BranchTrueFalseTotal
if $first == 64 1 1 2
381 1 ▶ $_[3] = - POSIX::HUGE_VAL(),return if $first == 0x41;
Branch: 1 branch
BranchTrueFalseTotal
if $first == 65 1 0 1
382 }
383 elsif(substr($_[4],$_[5],$_[6]) =~ /^.([-+]?)0*(\d+(?:\.\d+(?:[Ee][-+]?\d+)?)?)$/s) {
384 0 $_[3] = eval "$1$2";
385 0 return;
386 }
387  
388 0 die "REAL decode error\n";
389 }
390  
391  
392 30 ▶sub _dec_explicit {
Subroutine _dec_explicit: called CC=2 SCAR=6.9
393 # 0 1 2 3 4 5 6 7
394 # $optn, $op, $stash, $var, $buf, $pos, $len, $larr
395  
396 30 ▶ local $_[1][cCHILD][0][cVAR] = $_[1][cVAR] unless $_[1][cCHILD][0][cVAR];
Branch: 1 branch
BranchTrueFalseTotal
unless $_[1][6][0][2] 4 26 30
397  
398 30 _decode(
399 $_[0], #optn
400 $_[1]->[cCHILD], #ops
401 $_[2], #stash
402 $_[5], #pos
403 $_[5]+$_[6], #end
404 undef, #loop
405 $_[7],
406 $_[4], #buf
407 );
408 30 1;
409 }
410 391 ▶sub _dec_sequence {
Subroutine _dec_sequence: called CC=5 SCAR=16.3
411 # 0 1 2 3 4 5 6 7
412 # $optn, $op, $stash, $var, $buf, $pos, $len, $larr
413  
414 391 ▶ if (defined( my $ch = $_[1]->[cCHILD])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $ch = $_[1][6])) { } 391 0 391
415 391 ▶ _decode(
Branch: 1 branch
BranchTrueFalseTotal
defined $_[3] || $_[1][3] ? : 162 229 391
Condition100%5/5
defined $_[3] or $_[1][3]
l!l&&r!l&&!r
34128229
$_[1][3] && ($_[3] = [])
!ll
263128
MC/DC100%2/2
defined $_[3] or $_[1][3]
defined $_[3] $_[1][3]
MC/DC100%1/1
$_[1][3] && ($_[3] = [])
$_[1][3]
Truth table100%3/3
A or B
A= defined $_[3]B= $_[1][3]
ABresult
1X1
011
000
Truth table100%2/2
A
A= $_[1][3]
Aresult
00
11
416 $_[0], #optn
417 $ch, #ops
418 (defined($_[3]) || $_[1]->[cLOOP]) ? $_[2] : ($_[3]= {}), #stash
419 $_[5], #pos
420 $_[5]+$_[6], #end
421 $_[1]->[cLOOP] && ($_[3]=[]), #loop
422 $_[7],
423 $_[4], #buf
424 );
425 }
426 else {
427 0 $_[3] = substr($_[4],$_[5],$_[6]);
428 }
429 391 1;
430 }
431  
432  
433 8 ▶sub _dec_set {
Subroutine _dec_set: called CC=34 SCAR=51.7
434 # 0 1 2 3 4 5 6 7
435 # $optn, $op, $stash, $var, $buf, $pos, $len, $larr
436  
437 # decode SET OF the same as SEQUENCE OF
438 8 my $ch = $_[1]->[cCHILD];
439 8 ▶ goto &_dec_sequence if $_[1]->[cLOOP] or !defined($ch);
Branch: 1 branch
BranchTrueFalseTotal
if $_[1][3] or not defined $ch 0 8 8
Condition33%1/3
$_[1][3] or not defined $ch
l!l&&r!l&&!r
008
MC/DC0%0/2
$_[1][3] or not defined $ch
$_[1][3] not defined $ch
Truth table33%1/3
A or not(B)
A= $_[1][3]B= not defined $ch
ABresult
1X1
011
000
440  
441 8 my ($optn, $pos, $larr) = @_[0,5,7];
442 8 ▶ my $stash = defined($_[3]) ? $_[2] : ($_[3]={});
Branch: 1 branch
BranchTrueFalseTotal
defined $_[3] ? : 8 0 8
443 8 my $end = $pos + $_[6];
444 8 my @done;
445 my $extensions;
446  
447 8 ▶ while ($pos < $end) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos < $end) 26 8 34
448 26 ▶ my($tag,$len,$npos,$indef) = _decode_tl($_[4],$pos,$end,$larr)
Branch: 1 branch
BranchTrueFalseTotal
() = _decode_tl($_[4], $pos, $end, $larr) or die "decode error" 26 0 26
449 or die "decode error";
450  
451 26 my ($idx, $any, $done) = (-1);
452  
453 SET_OP:
454 26 foreach my $op (@$ch) {
455 69 $idx++;
456 69 ▶ if (length($op->[cTAG])) {
Branch: 4 branches
BranchTrueFalseTotal
if (length $op->[0]) { } 55 14 69
elsif ($op->[1] == 14) { } 0 14 14
elsif ($op->[1] == 15) { } 0 14 14
elsif ($op->[1] == 18) { } 14 0 14
457 55 ▶ if ($tag eq $op->[cTAG]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag eq $op->[0]) 25 30 55
458 25 my $var = $op->[cVAR];
459 25 &{$decode[$op->[cTYPE]]}(
460 $optn,
461 $op,
462 $stash,
463 # We send 1 if there is not var as if there is the decode
464 # should be getting undef. So if it does not get undef
465 # it knows it has no variable
466 25 ▶ (defined($var) ? $stash->{$var} : 1),
Branch: 1 branch
BranchTrueFalseTotal
defined $var ? : 25 0 25
467 $_[4],$npos,$len,$larr,
468 );
469 25 $done = $idx;
470 25 last SET_OP;
471 }
472 30 ▶ if ($tag eq ($op->[cTAG] | pack("C",ASN_CONSTRUCTOR))
Branch: 1 branch
BranchTrueFalseTotal
if ($tag eq ($op->[0] | " ") and my $ctr = $ctr[$op->[1]]) 0 30 30
Condition33%1/3
$tag eq ($op->[0] | " ") and my $ctr = $ctr[$op->[1]]
!ll&&!rl&&r
3000
MC/DC0%0/2
$tag eq ($op->[0] | " ") and my $ctr = $ctr[$op->[1]]
$tag eq ($op->[0] | " ") my $ctr = $ctr[$op->[1]]
Truth table33%1/3
A and B
A= $tag eq ($op->[0] | " ")B= my $ctr = $ctr[$op->[1]]
ABresult
0X0
100
111
473 and my $ctr = $ctr[$op->[cTYPE]])
474 {
475 0 _decode(
476 $optn,
477 [$op],
478 undef,
479 $npos,
480 $npos+$len,
481 (\my @ctrlist),
482 $larr,
483 $_[4],
484 );
485  
486 0 ▶ $stash->{$op->[cVAR]} = &{$ctr}(@ctrlist)
Branch: 1 branch
BranchTrueFalseTotal
if defined $op->[2] 0 0 0
487 if defined $op->[cVAR];
488 0 $done = $idx;
489 0 last SET_OP;
490 }
491 30 next SET_OP;
492 }
493 elsif ($op->[cTYPE] == opANY) {
494 0 $any = $idx;
495 }
496 elsif ($op->[cTYPE] == opCHOICE) {
497 0 my $var = $op->[cVAR];
498 0 foreach my $cop (@{$op->[cCHILD]}) {
499 0 ▶ if ($tag eq $cop->[cTAG]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag eq $cop->[0]) 0 0 0
500 0 ▶ my $nstash = defined($var) ? ($stash->{$var}={}) : $stash;
Branch: 1 branch
BranchTrueFalseTotal
defined $var ? : 0 0 0
501  
502 0 &{$decode[$cop->[cTYPE]]}(
503 $optn,
504 $cop,
505 $nstash,
506 0 $nstash->{$cop->[cVAR]},
507 $_[4],$npos,$len,$larr,
508 );
509 0 $done = $idx;
510 0 last SET_OP;
511 }
512 0 ▶ if ($tag eq ($cop->[cTAG] | pack("C",ASN_CONSTRUCTOR))
Branch: 1 branch
BranchTrueFalseTotal
if ($tag eq ($cop->[0] | " ") and my $ctr = $ctr[$cop->[1]]) 0 0 0
Condition0%0/3
$tag eq ($cop->[0] | " ") and my $ctr = $ctr[$cop->[1]]
!ll&&!rl&&r
000
MC/DC0%0/2
$tag eq ($cop->[0] | " ") and my $ctr = $ctr[$cop->[1]]
$tag eq ($cop->[0] | " ") my $ctr = $ctr[$cop->[1]]
Truth table0%0/3
A and B
A= $tag eq ($cop->[0] | " ")B= my $ctr = $ctr[$cop->[1]]
ABresult
0X0
100
111
513 and my $ctr = $ctr[$cop->[cTYPE]])
514 {
515 0 ▶ my $nstash = defined($var) ? ($stash->{$var}={}) : $stash;
Branch: 1 branch
BranchTrueFalseTotal
defined $var ? : 0 0 0
516  
517 0 _decode(
518 $optn,
519 [$cop],
520 undef,
521 $npos,
522 $npos+$len,
523 (\my @ctrlist),
524 $larr,
525 $_[4],
526 );
527  
528 0 $nstash->{$cop->[cVAR]} = &{$ctr}(@ctrlist);
529 0 $done = $idx;
530 0 last SET_OP;
531 }
532 }
533 }
534 elsif ($op->[cTYPE] == opEXTENSIONS) {
535 14 $extensions = $idx;
536 }
537 else {
538 0 die "internal error";
539 }
540 }
541  
542 26 ▶ if (!defined($done) and defined($any)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $done and defined $any) 0 26 26
Condition66%2/3
not defined $done and defined $any
!ll&&!rl&&r
2510
MC/DC0%0/2
not defined $done and defined $any
not defined $done defined $any
Truth table66%2/3
not(A) and B
A= not defined $doneB= defined $any
ABresult
0X0
100
111
543 0 my $var = $ch->[$any][cVAR];
544 0 ▶ $stash->{$var} = substr($_[4],$pos,$len+$npos-$pos) if defined $var;
Branch: 1 branch
BranchTrueFalseTotal
if defined $var 0 0 0
545 0 $done = $any;
546 }
547  
548 26 ▶ if( !defined($done) && defined($extensions) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $done and defined $extensions) 1 25 26
Condition66%2/3
not defined $done and defined $extensions
!ll&&!rl&&r
2501
MC/DC50%1/2
not defined $done and defined $extensions
not defined $done defined $extensions
Truth table66%2/3
not(A) and B
A= not defined $doneB= defined $extensions
ABresult
0X0
100
111
549 1 $done = $extensions;
550 }
551  
552 26 ▶ die "decode error" if !defined($done) or $done[$done]++;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $done or $done[$done]++ 0 26 26
Condition33%1/3
not defined $done or $done[$done]++
l!l&&r!l&&!r
0026
MC/DC0%0/2
not defined $done or $done[$done]++
not defined $done $done[$done]++
Truth table33%1/3
not(A) or B
A= not defined $doneB= $done[$done]++
ABresult
1X1
011
000
553  
554 26 $pos = $npos + $len + $indef;
555 }
556  
557 8 ▶ die "decode error" unless $end == $pos;
Branch: 1 branch
BranchTrueFalseTotal
unless $end == $pos 0 8 8
558  
559 8 foreach my $idx (0..$#{$ch}) {
560 30 ▶ die "decode error" unless $done[$idx] or $ch->[$idx][cEXT] or $ch->[$idx][cTYPE] == opEXTENSIONS;
Branch: 1 branch
BranchTrueFalseTotal
unless $done[$idx] or $ch->[$idx][5] or $ch->[$idx][1] == 18 0 30 30
Condition83%5/6
$done[$idx] or $ch->[$idx][5] or $ch->[$idx][1] == 18
l!l&&r!l&&!r
2730
$done[$idx] or $ch->[$idx][5]
l!l&&r!l&&!r
2613
MC/DC0%0/3
$done[$idx] or $ch->[$idx][5] or $ch->[$idx][1] == 18
$done[$idx] $ch->[$idx][5] $ch->[$idx][1] == 18
Truth table75%3/4
A or B or C
A= $done[$idx]B= $ch->[$idx][5]C= $ch->[$idx][1] == 18
ABCresult
1XX1
01X1
0011
0000
561 }
562  
563 8 1;
564 }
565  
566  
567 24 my %_dec_time_opt = ( unixtime => 0, withzone => 1, raw => 2);
568  
569 44 ▶sub _dec_time {
Subroutine _dec_time: called CC=12 SCAR=24.9
570 # 0 1 2 3 4 5 6
571 # $optn, $op, $stash, $var, $buf, $pos, $len
572  
573 44 ▶ my $mode = $_dec_time_opt{$_[0]->{'decode_time'} || ''} || 0;
Condition100%4/4
$_dec_time_opt{$_[0]{'decode_time'} or ''} || 0
l!l
1034
$_[0]{'decode_time'} || ''
l!l
1034
MC/DC100%1/1
$_dec_time_opt{$_[0]{'decode_time'} or ''} || 0
$_dec_time_opt{$_[0]{'decode_time'} or ''}
MC/DC100%1/1
$_[0]{'decode_time'} || ''
$_[0]{'decode_time'}
Truth table100%2/2
A
A= $_dec_time_opt{$_[0]{'decode_time'} or ''}
Aresult
11
00
Truth table100%2/2
A
A= $_[0]{'decode_time'}
Aresult
11
00
574  
575 44 ▶ if ($mode == 2 or $_[6] == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode == 2 or $_[6] == 0) 10 34 44
Condition66%2/3
$mode == 2 or $_[6] == 0
l!l&&r!l&&!r
10034
MC/DC50%1/2
$mode == 2 or $_[6] == 0
$mode == 2 $_[6] == 0
Truth table66%2/3
A or B
A= $mode == 2B= $_[6] == 0
ABresult
1X1
011
000
576 10 $_[3] = substr($_[4],$_[5],$_[6]);
577 10 return;
578 }
579  
580 34 ▶ my @bits = (substr($_[4],$_[5],$_[6])
Branch: 1 branch
BranchTrueFalseTotal
my(@bits) = substr($_[4], $_[5], $_[6]) =~ /^((?:\d\d)?\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)((?:\.\d{1,3})?)(([-+])(\d\d)(\d\d)|Z)/ or die "bad time format" 34 0 34
581 =~ /^((?:\d\d)?\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)((?:\.\d{1,3})?)(([-+])(\d\d)(\d\d)|Z)/)
582 or die "bad time format";
583  
584 # two digit year (UTCTime), RFC 5280 4.1.2.5.1: 50 - 99 is 19YY, 00 - 49 is 20YY
585 34 ▶ if (length $bits[0] == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $bits[0] == 2) 25 9 34
586 25 ▶ $bits[0] += ($bits[0] < 50) ? 2000 : 1900;
Branch: 1 branch
BranchTrueFalseTotal
$bits[0] < 50 ? : 21 4 25
587 }
588 34 $bits[1] -= 1;
589 34 require Time::Local;
590 34 my $time = Time::Local::timegm_modern(@bits[5,4,3,2,1,0]);
591 34 ▶ $time += $bits[6] if length $bits[6];
Branch: 1 branch
BranchTrueFalseTotal
if length $bits[6] 1 33 34
592 34 my $offset = 0;
593 34 ▶ if ($bits[7] ne 'Z') {
Branch: 1 branch
BranchTrueFalseTotal
if ($bits[7] ne "Z") 5 29 34
594 5 $offset = $bits[9] * 3600 + $bits[10] * 60;
595 5 ▶ $offset = -$offset if $bits[8] eq '-';
Branch: 1 branch
BranchTrueFalseTotal
if $bits[8] eq "-" 1 4 5
596 5 $time -= $offset;
597 }
598 34 ▶ $_[3] = $mode ? [$time,$offset] : $time;
Branch: 1 branch
BranchTrueFalseTotal
$mode ? : 0 34 34
599 }
600  
601  
602 2 ▶sub _dec_utf8 {
Subroutine _dec_utf8: called CC=1 SCAR=0.0
603 # 0 1 2 3 4 5 6
604 # $optn, $op, $stash, $var, $buf, $pos, $len
605  
606 24 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
607 24 unless (CHECK_UTF8) {
608 local $SIG{__DIE__};
609 eval { require bytes } and 'bytes'->unimport;
610 eval { require utf8 } and 'utf8'->import;
611 }
612 }
613  
614 2 if (CHECK_UTF8) {
615 2 $_[3] = Encode::decode('utf8', substr($_[4],$_[5],$_[6]));
616 }
617 else {
618 $_[3] = (substr($_[4],$_[5],$_[6]) =~ /(.*)/s)[0];
619 }
620  
621 2 1;
622 }
623  
624  
625 1183 ▶sub _decode_tl {
Subroutine _decode_tl: called CC=13 SCAR=25.8
626 1183 my($pos,$end,$larr) = @_[1,2,3];
627  
628 1183 ▶ return if $pos >= $end;
Branch: 1 branch
BranchTrueFalseTotal
if $pos >= $end 25 1158 1183
629  
630 1158 my $indef = 0;
631  
632 1158 my $tag = substr($_[0], $pos++, 1);
633  
634 1158 ▶ if((unpack("C",$tag) & 0x1f) == 0x1f) {
Branch: 1 branch
BranchTrueFalseTotal
if ((unpack("C", $tag) & 31) == 31) 1 1157 1158
635 1 my $b;
636 1 my $n=1;
637 1 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$b & 128 and do { do { return if $pos >= $end; $tag .= substr($_[0], $pos++, 1); $b = ord substr($tag, -1) } } 4 0 4
638 5 ▶ return if $pos >= $end;
Branch: 1 branch
BranchTrueFalseTotal
if $pos >= $end 1 4 5
639 4 $tag .= substr($_[0],$pos++,1);
640 4 $b = ord substr($tag,-1);
641 } while($b & 0x80);
642 }
643 1157 ▶ return if $pos >= $end;
Branch: 1 branch
BranchTrueFalseTotal
if $pos >= $end 0 1157 1157
644  
645 1157 my $len = ord substr($_[0],$pos++,1);
646  
647 1157 ▶ if($len & 0x80) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len & 128) 132 1025 1157
648 132 $len &= 0x7f;
649  
650 132 ▶ if ($len) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len) { } 122 10 132
651 122 ▶ return if $pos+$len > $end ;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + $len > $end 0 122 122
652  
653 122 ▶ my $padding = $len < 4 ? "\0" x (4 - $len) : "";
Branch: 1 branch
BranchTrueFalseTotal
$len < 4 ? : 122 0 122
654 122 ($len,$pos) = (unpack("N", $padding . substr($_[0],$pos,$len)), $pos+$len);
655 }
656 else {
657 10 ▶ unless (exists $larr->{$pos}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $larr->{$pos}) 5 5 10
658 5 ▶ _scan_indef($_[0],$pos,$end,$larr) or return;
Branch: 1 branch
BranchTrueFalseTotal
_scan_indef($_[0], $pos, $end, $larr) or return 4 1 5
659 }
660 9 $indef = 2;
661 9 $len = $larr->{$pos};
662 }
663 }
664  
665 1156 ▶ return if $pos+$len+$indef > $end;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + $len + $indef > $end 0 1156 1156
666  
667 # return the tag, the length of the data, the position of the data
668 # and the number of extra bytes for indefinite encoding
669  
670 1156 ($tag, $len, $pos, $indef);
671 }
672  
673 5 ▶sub _scan_indef {
Subroutine _scan_indef: called CC=13 SCAR=27.1
674 5 my($pos,$end,$larr) = @_[1,2,3];
675 5 my @depth = ( $pos );
676  
677 5 ▶ while(@depth) {
Branch: 1 branch
BranchTrueFalseTotal
if (@depth) 27 4 31
678 27 ▶ return if $pos+2 > $end;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + 2 > $end 0 27 27
679  
680 27 ▶ if (substr($_[0],$pos,2) eq "\0\0") {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($_[0], $pos, 2) eq "\0\0") 10 17 27
681 10 my $end = $pos;
682 10 my $stref = shift @depth;
683 # replace pos with length = end - pos
684 10 $larr->{$stref} = $end - $stref;
685 10 $pos += 2;
686 10 next;
687 }
688 17 ▶ return if $pos >= $end;
Branch: 1 branch
BranchTrueFalseTotal
if $pos >= $end 0 17 17
689  
690 17 my $tag = substr($_[0], $pos++, 1);
691  
692 17 ▶ if((unpack("C",$tag) & 0x1f) == 0x1f) {
Branch: 1 branch
BranchTrueFalseTotal
if ((unpack("C", $tag) & 31) == 31) 1 16 17
693 1 my $b;
694 1 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$b & 128 and do { do { return if $pos >= $end; $tag .= substr($_[0], $pos++, 1); $b = ord substr($tag, -1) } } 2 0 2
695 3 ▶ return if $pos >= $end;
Branch: 1 branch
BranchTrueFalseTotal
if $pos >= $end 1 2 3
696 2 $tag .= substr($_[0],$pos++,1);
697 2 $b = ord substr($tag,-1);
698 } while($b & 0x80);
699 }
700 16 ▶ return if $pos >= $end;
Branch: 1 branch
BranchTrueFalseTotal
if $pos >= $end 0 16 16
701  
702 16 my $len = ord substr($_[0],$pos++,1);
703  
704 16 ▶ if($len & 0x80) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len & 128) { } 6 10 16
705 6 ▶ if ($len &= 0x7f) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len &= 127) { } 0 6 6
706 0 ▶ return if $pos+$len > $end ;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + $len > $end 0 0 0
707  
708 0 ▶ my $padding = $len < 4 ? "\0" x (4 - $len) : "";
Branch: 1 branch
BranchTrueFalseTotal
$len < 4 ? : 0 0 0
709 0 $pos += $len + unpack("N", $padding . substr($_[0],$pos,$len));
710 }
711 else {
712 # reserve another list element
713 6 unshift @depth, $pos;
714 }
715 }
716 else {
717 10 $pos += $len;
718 }
719 }
720  
721 4 1;
722 }
723  
724 1 ▶sub _ctr_string { join '', @_ }
Subroutine _ctr_string: called CC=1 SCAR=0.0
725  
726 0 ▶sub _ctr_bitstring {
Subroutine _ctr_bitstring: not called CC=1 SCAR=6.9
727 0 [ join('', map { $_->[0] } @_), $_[-1]->[1] ]
728 }
729  
730 8 ▶sub _dec_bcd {
Subroutine _dec_bcd: called CC=1 SCAR=0.0
731 # 0 1 2 3 4 5 6
732 # $optn, $op, $stash, $var, $buf, $pos, $len
733  
734 8 ($_[3] = unpack("H*", substr($_[4],$_[5],$_[6]))) =~ s/[fF]$//;
735 8 1;
736 }
737 24 1;
738  
↑ Summary ASN1/Debug.pm »