OpenCoverage

a_bitstr.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/a_bitstr.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len)-
3{-
4 return
executed 21 times by 1 test: return ASN1_STRING_set(x, d, len);
Executed by:
  • libcrypto.so.1.1
ASN1_STRING_set(x, d, len);
executed 21 times by 1 test: return ASN1_STRING_set(x, d, len);
Executed by:
  • libcrypto.so.1.1
21
5}-
6-
7int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)-
8{-
9 int ret, j, bits, len;-
10 unsigned char *p, *d;-
11-
12 if (a ==
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 309577 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-309577
13 ((void *)0)
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 309577 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-309577
14 )-
15 return
never executed: return 0;
0;
never executed: return 0;
0
16-
17 len = a->length;-
18-
19 if (len > 0
len > 0Description
TRUEevaluated 176496 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 133081 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
133081-176496
20 if (a->flags & 0x08
a->flags & 0x08Description
TRUEevaluated 176466 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 30 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
30-176466
21 bits = (int)a->flags & 0x07;-
22 }
executed 176466 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else {
176466
23 for (; len > 0
len > 0Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
; len--) {
0-30
24 if (a->data[len - 1]
a->data[len - 1]Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-30
25 break;
executed 30 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
30
26 }
never executed: end of block
0
27 j = a->data[len - 1];-
28 if (j & 0x01
j & 0x01Description
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-30
29 bits = 0;
never executed: bits = 0;
0
30 else if (j & 0x02
j & 0x02Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 18 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
12-18
31 bits = 1;
executed 12 times by 1 test: bits = 1;
Executed by:
  • libcrypto.so.1.1
12
32 else if (j & 0x04
j & 0x04Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-18
33 bits = 2;
never executed: bits = 2;
0
34 else if (j & 0x08
j & 0x08Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
6-12
35 bits = 3;
executed 6 times by 1 test: bits = 3;
Executed by:
  • libcrypto.so.1.1
6
36 else if (j & 0x10
j & 0x10Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-12
37 bits = 4;
never executed: bits = 4;
0
38 else if (j & 0x20
j & 0x20Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
6
39 bits = 5;
executed 6 times by 1 test: bits = 5;
Executed by:
  • libcrypto.so.1.1
6
40 else if (j & 0x40
j & 0x40Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-6
41 bits = 6;
executed 6 times by 1 test: bits = 6;
Executed by:
  • libcrypto.so.1.1
6
42 else if (j & 0x80
j & 0x80Description
TRUEnever evaluated
FALSEnever evaluated
)
0
43 bits = 7;
never executed: bits = 7;
0
44 else-
45 bits = 0;
never executed: bits = 0;
0
46 }-
47 } else-
48 bits = 0;
executed 133081 times by 1 test: bits = 0;
Executed by:
  • libcrypto.so.1.1
133081
49-
50 ret = 1 + len;-
51 if (pp ==
pp == ((void *)0)Description
TRUEevaluated 235356 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 74221 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
74221-235356
52 ((void *)0)
pp == ((void *)0)Description
TRUEevaluated 235356 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 74221 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
74221-235356
53 )-
54 return
executed 235356 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 235356 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
235356
55-
56 p = *pp;-
57-
58 *(p++) = (unsigned char)bits;-
59 d = a->data;-
60 if (len > 0
len > 0Description
TRUEevaluated 42006 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 32215 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
32215-42006
61 memcpy(p, d, len);-
62 p += len;-
63 p[-1] &= (0xff << bits);-
64 }
executed 42006 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
42006
65 *pp = p;-
66 return
executed 74221 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 74221 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
74221
67}-
68-
69ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,-
70 const unsigned char **pp, long len)-
71{-
72 ASN1_BIT_STRING *ret = -
73 ((void *)0)-
74 ;-
75 const unsigned char *p;-
76 unsigned char *s;-
77 int i;-
78-
79 if (len < 1
len < 1Description
TRUEevaluated 1244 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 146638 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
1244-146638
80 i = 152;-
81 goto
executed 1244 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
err;
executed 1244 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
1244
82 }-
83-
84 if (len > 0x7fffffff
len > 0x7fffffffDescription
TRUEnever evaluated
FALSEevaluated 146638 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-146638
85 i = 151;-
86 goto
never executed: goto err;
err;
never executed: goto err;
0
87 }-
88-
89 if ((
(a == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 146638 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a ==
(a == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 146638 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-146638
90 ((void *)0)
(a == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 146638 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-146638
91 )
(a == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 146638 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| ((*
((*a) == ((void *)0) )Description
TRUEevaluated 22982 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 123656 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a) ==
((*a) == ((void *)0) )Description
TRUEevaluated 22982 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 123656 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-146638
92 ((void *)0)
((*a) == ((void *)0) )Description
TRUEevaluated 22982 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 123656 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
22982-123656
93 )
((*a) == ((void *)0) )Description
TRUEevaluated 22982 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 123656 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
22982-123656
94 if ((
(ret = ASN1_BI...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 22982 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
ret = ASN1_BIT_STRING_new()) ==
(ret = ASN1_BI...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 22982 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-22982
95 ((void *)0)
(ret = ASN1_BI...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 22982 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-22982
96 )-
97 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
98 ((void *)0)
never executed: return ((void *)0) ;
0
99 ;
never executed: return ((void *)0) ;
0
100 }
executed 22982 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else
22982
101 ret = (*a);
executed 123656 times by 1 test: ret = (*a);
Executed by:
  • libcrypto.so.1.1
123656
102-
103 p = *pp;-
104 i = *(p++);-
105 if (i > 7
i > 7Description
TRUEevaluated 626 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 146012 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
626-146012
106 i = 220;-
107 goto
executed 626 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
err;
executed 626 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
626
108 }-
109-
110-
111-
112-
113 ret->flags &= ~(0x08 | 0x07);-
114 ret->flags |= (0x08 | i);-
115-
116 if (len-- > 1
len-- > 1Description
TRUEevaluated 92146 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 53866 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
53866-92146
117 s = CRYPTO_malloc((int)len, __FILE__, 117);-
118 if (s ==
s == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 92146 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-92146
119 ((void *)0)
s == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 92146 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-92146
120 ) {-
121 i = (1|64);-
122 goto
never executed: goto err;
err;
never executed: goto err;
0
123 }-
124 memcpy(s, p, (int)len);-
125 s[len - 1] &= (0xff << i);-
126 p += len;-
127 }
executed 92146 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else
92146
128 s =
executed 53866 times by 1 test: s = ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
53866
129 ((void *)0)
executed 53866 times by 1 test: s = ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
53866
130 ;
executed 53866 times by 1 test: s = ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
53866
131-
132 ret->length = (int)len;-
133 CRYPTO_free(ret->data, __FILE__, 129);-
134 ret->data = s;-
135 ret->type = 3;-
136 if (a !=
a != ((void *)0)Description
TRUEevaluated 146012 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-146012
137 ((void *)0)
a != ((void *)0)Description
TRUEevaluated 146012 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-146012
138 )-
139 (*
executed 146012 times by 1 test: (*a) = ret;
Executed by:
  • libcrypto.so.1.1
a) = ret;
executed 146012 times by 1 test: (*a) = ret;
Executed by:
  • libcrypto.so.1.1
146012
140 *pp = p;-
141 return
executed 146012 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 146012 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
146012
142 err:-
143 ERR_put_error(13,(189),(i),__FILE__,137);-
144 if ((
(a == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 1870 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a ==
(a == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 1870 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1870
145 ((void *)0)
(a == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 1870 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1870
146 )
(a == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 1870 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| (*
(*a != ret)Description
TRUEevaluated 807 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1063 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a != ret)
(*a != ret)Description
TRUEevaluated 807 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1063 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-1870
147 ASN1_BIT_STRING_free(ret);
executed 807 times by 1 test: ASN1_BIT_STRING_free(ret);
Executed by:
  • libcrypto.so.1.1
807
148 return
executed 1870 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
executed 1870 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
1870
149 ((void *)0)
executed 1870 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
1870
150 ;
executed 1870 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
1870
151}-
152-
153-
154-
155-
156int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)-
157{-
158 int w, v, iv;-
159 unsigned char *c;-
160-
161 w = n / 8;-
162 v = 1 << (7 - (n & 0x07));-
163 iv = ~v;-
164 if (!value
!valueDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-24
165 v = 0;
never executed: v = 0;
0
166-
167 if (a ==
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
168 ((void *)0)
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
169 )-
170 return
never executed: return 0;
0;
never executed: return 0;
0
171-
172 a->flags &= ~(0x08 | 0x07);-
173-
174 if ((
(a->length < (w + 1))Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a->length < (w + 1))
(a->length < (w + 1))Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| (
(a->data == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a->data ==
(a->data == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14
175 ((void *)0)
(a->data == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14
176 )
(a->data == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-14
177 if (!value
!valueDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-10
178 return
never executed: return 1;
1;
never executed: return 1;
0
179 c = CRYPTO_clear_realloc(a->data, a->length, w + 1, __FILE__, 165);-
180 if (c ==
c == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10
181 ((void *)0)
c == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10
182 ) {-
183 ERR_put_error(13,(183),((1|64)),__FILE__,167);-
184 return
never executed: return 0;
0;
never executed: return 0;
0
185 }-
186 if (w + 1 - a->length > 0
w + 1 - a->length > 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-10
187 memset(c + a->length, 0, w + 1 - a->length);
executed 10 times by 1 test: memset(c + a->length, 0, w + 1 - a->length);
Executed by:
  • libcrypto.so.1.1
10
188 a->data = c;-
189 a->length = w + 1;-
190 }
executed 10 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
10
191 a->data[w] = ((a->data[w]) & iv) | v;-
192 while ((
(a->length > 0)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
a->length > 0)
(a->length > 0)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
&& (
(a->data[a->length - 1] == 0)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a->data[a->length - 1] == 0)
(a->data[a->length - 1] == 0)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-24
193 a->length--;
never executed: a->length--;
0
194 return
executed 24 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 24 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
24
195}-
196-
197int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n)-
198{-
199 int w, v;-
200-
201 w = n / 8;-
202 v = 1 << (7 - (n & 0x07));-
203 if ((
(a == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 47413 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a ==
(a == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 47413 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-47413
204 ((void *)0)
(a == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 47413 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-47413
205 )
(a == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 47413 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| (
(a->length < (w + 1))Description
TRUEevaluated 5893 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 41520 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a->length < (w + 1))
(a->length < (w + 1))Description
TRUEevaluated 5893 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 41520 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| (
(a->data == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 41520 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a->data ==
(a->data == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 41520 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-47413
206 ((void *)0)
(a->data == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 41520 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-41520
207 )
(a->data == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 41520 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-41520
208 return
executed 5893 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
0;
executed 5893 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
5893
209 return
executed 41520 times by 1 test: return ((a->data[w] & v) != 0);
Executed by:
  • libcrypto.so.1.1
((a->data[w] & v) != 0);
executed 41520 times by 1 test: return ((a->data[w] & v) != 0);
Executed by:
  • libcrypto.so.1.1
41520
210}-
211-
212-
213-
214-
215-
216-
217-
218int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a,-
219 const unsigned char *flags, int flags_len)-
220{-
221 int i, ok;-
222-
223 if (!a
!aDescription
TRUEnever evaluated
FALSEnever evaluated
|| !a->data
!a->dataDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
224 return
never executed: return 1;
1;
never executed: return 1;
0
225-
226-
227-
228-
229 ok = 1;-
230 for (i = 0; i < a->length
i < a->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
&& ok
okDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
231 unsigned char mask = i < flags_len
i < flags_lenDescription
TRUEnever evaluated
FALSEnever evaluated
? ~flags[i] : 0xff;
0
232-
233 ok = (a->data[i] & mask) == 0;-
234 }
never executed: end of block
0
235 return
never executed: return ok;
ok;
never executed: return ok;
0
236}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2