OpenCoverage

a_d2i_fp.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/a_d2i_fp.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6void *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x)-
7{-
8 BIO *b;-
9 void *ret;-
10-
11 if ((
(b = BIO_new(B...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
b = BIO_new(BIO_s_file())) ==
(b = BIO_new(B...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
12 ((void *)0)
(b = BIO_new(B...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
13 ) {-
14 ERR_put_error(13,(109),(7),__FILE__,27);-
15 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
16 ((void *)0)
never executed: return ((void *)0) ;
0
17 ;
never executed: return ((void *)0) ;
0
18 }-
19 BIO_ctrl(b,106,0x00,(char *)(in));-
20 ret = ASN1_d2i_bio(xnew, d2i, b, x);-
21 BIO_free(b);-
22 return
never executed: return ret;
ret;
never executed: return ret;
0
23}-
24-
25-
26void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x)-
27{-
28 BUF_MEM *b = -
29 ((void *)0)-
30 ;-
31 const unsigned char *p;-
32 void *ret = -
33 ((void *)0)-
34 ;-
35 int len;-
36-
37 len = asn1_d2i_read_bio(in, &b);-
38 if (len < 0
len < 0Description
TRUEnever evaluated
FALSEevaluated 83 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-83
39 goto
never executed: goto err;
err;
never executed: goto err;
0
40-
41 p = (unsigned char *)b->data;-
42 ret = d2i(x, &p, len);-
43 err:
code before this statement executed 83 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
83
44 BUF_MEM_free(b);-
45 return
executed 83 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 83 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
83
46}-
47-
48-
49-
50void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x)-
51{-
52 BUF_MEM *b = -
53 ((void *)0)-
54 ;-
55 const unsigned char *p;-
56 void *ret = -
57 ((void *)0)-
58 ;-
59 int len;-
60-
61 len = asn1_d2i_read_bio(in, &b);-
62 if (len < 0
len < 0Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1457 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
14-1457
63 goto
executed 14 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
err;
executed 14 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
14
64-
65 p = (const unsigned char *)b->data;-
66 ret = ASN1_item_d2i(x, &p, len, it);-
67 err:
code before this statement executed 1457 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
1457
68 BUF_MEM_free(b);-
69 return
executed 1471 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 1471 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
1471
70}-
71-
72-
73void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x)-
74{-
75 BIO *b;-
76 char *ret;-
77-
78 if ((
(b = BIO_new(B...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
b = BIO_new(BIO_s_file())) ==
(b = BIO_new(B...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
79 ((void *)0)
(b = BIO_new(B...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
80 ) {-
81 ERR_put_error(13,(206),(7),__FILE__,82);-
82 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
83 ((void *)0)
never executed: return ((void *)0) ;
0
84 ;
never executed: return ((void *)0) ;
0
85 }-
86 BIO_ctrl(b,106,0x00,(char *)(in));-
87 ret = ASN1_item_d2i_bio(it, b, x);-
88 BIO_free(b);-
89 return
never executed: return ret;
ret;
never executed: return ret;
0
90}-
91-
92-
93-
94-
95int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)-
96{-
97 BUF_MEM *b;-
98 unsigned char *p;-
99 int i;-
100 size_t want = 8;-
101 uint32_t eos = 0;-
102 size_t off = 0;-
103 size_t len = 0;-
104-
105 const unsigned char *q;-
106 long slen;-
107 int inf, tag, xclass;-
108-
109 b = BUF_MEM_new();-
110 if (b ==
b == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1554 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1554
111 ((void *)0)
b == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1554 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1554
112 ) {-
113 ERR_put_error(13,(107),((1|64)),__FILE__,110);-
114 return
never executed: return -1;
-1;
never executed: return -1;
0
115 }-
116-
117 ERR_clear_error();-
118 for (;;) {-
119 if (want >= (len - off)
want >= (len - off)Description
TRUEevaluated 543238 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-543238
120 want -= (len - off);-
121-
122 if (len + want < len
len + want < lenDescription
TRUEnever evaluated
FALSEevaluated 543238 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| !BUF_MEM_grow_clean(b, len + want)
!BUF_MEM_grow_...b, len + want)Description
TRUEnever evaluated
FALSEevaluated 543238 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-543238
123 ERR_put_error(13,(107),((1|64)),__FILE__,120);-
124 goto
never executed: goto err;
err;
never executed: goto err;
0
125 }-
126 i = BIO_read(in, &(b->data[len]), want);-
127 if ((
(i < 0)Description
TRUEevaluated 2555 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 540683 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
i < 0)
(i < 0)Description
TRUEevaluated 2555 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 540683 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& ((
((len - off) == 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2553 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
len - off) == 0)
((len - off) == 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2553 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
2-540683
128 ERR_put_error(13,(107),(142),__FILE__,125);-
129 goto
executed 2 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
err;
executed 2 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
2
130 }-
131 if (i > 0
i > 0Description
TRUEevaluated 540588 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2648 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
2648-540588
132 if (len + i < len
len + i < lenDescription
TRUEnever evaluated
FALSEevaluated 540588 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-540588
133 ERR_put_error(13,(107),(155),__FILE__,130);-
134 goto
never executed: goto err;
err;
never executed: goto err;
0
135 }-
136 len += i;-
137 }
executed 540588 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
540588
138 }
executed 543236 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
543236
139-
140-
141 p = (unsigned char *)&(b->data[off]);-
142 q = p;-
143 inf = ASN1_get_object(&q, &slen, &tag, &xclass, len - off);-
144 if (inf & 0x80
inf & 0x80Description
TRUEevaluated 34285 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 508951 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
34285-508951
145 unsigned long e;-
146-
147 e = (int)( (ERR_peek_error()) & 0xFFFL);-
148 if (e != 155
e != 155Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 34284 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
1-34284
149 goto
executed 1 time by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
err;
executed 1 time by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
1
150 else-
151 ERR_clear_error();
executed 34284 times by 1 test: ERR_clear_error();
Executed by:
  • libcrypto.so.1.1
34284
152 }-
153 i = q - p;-
154 off += i;-
155-
156 if (inf & 1
inf & 1Description
TRUEevaluated 159127 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 384108 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
159127-384108
157-
158 if (eos ==
eos == (4294967295U)Description
TRUEnever evaluated
FALSEevaluated 159127 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-159127
159 (4294967295U)
eos == (4294967295U)Description
TRUEnever evaluated
FALSEevaluated 159127 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-159127
160 ) {-
161 ERR_put_error(13,(107),(123),__FILE__,156);-
162 goto
never executed: goto err;
err;
never executed: goto err;
0
163 }-
164 eos++;-
165 want = 8;-
166 }
executed 159127 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else if (eos
eosDescription
TRUEevaluated 383748 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 360 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& (
(slen == 0)Description
TRUEevaluated 205335 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 178413 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
slen == 0)
(slen == 0)Description
TRUEevaluated 205335 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 178413 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& (
(tag == 0)Description
TRUEevaluated 159110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 46225 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
tag == 0)
(tag == 0)Description
TRUEevaluated 159110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 46225 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
360-383748
167-
168 eos--;-
169 if (eos == 0
eos == 0Description
TRUEevaluated 1186 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 157924 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
1186-157924
170 break;
executed 1186 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
1186
171 else-
172 want = 8;
executed 157924 times by 1 test: want = 8;
Executed by:
  • libcrypto.so.1.1
157924
173 } else {-
174-
175 want = slen;-
176 if (want > (len - off)
want > (len - off)Description
TRUEevaluated 34284 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 190714 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
34284-190714
177 size_t chunk_max = (16 * 1024);-
178-
179 want -= (len - off);-
180 if (want > 0x7fffffff
want > 0x7fffffffDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 34283 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
||
1-34283
181 len + want < len
len + want < lenDescription
TRUEnever evaluated
FALSEevaluated 34283 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-34283
182 ERR_put_error(13,(107),(155),__FILE__,177);-
183 goto
executed 1 time by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
err;
executed 1 time by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
1
184 }-
185 while (want > 0
want > 0Description
TRUEevaluated 34289 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 34273 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
34273-34289
186-
187-
188-
189-
190-
191-
192 size_t chunk = want > chunk_max
want > chunk_maxDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 34278 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
? chunk_max : want;
11-34278
193-
194 if (!BUF_MEM_grow_clean(b, len + chunk)
!BUF_MEM_grow_..., len + chunk)Description
TRUEnever evaluated
FALSEevaluated 34289 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-34289
195 ERR_put_error(13,(107),((1|64)),__FILE__,190);-
196 goto
never executed: goto err;
err;
never executed: goto err;
0
197 }-
198 want -= chunk;-
199 while (chunk > 0
chunk > 0Description
TRUEevaluated 34290 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 34279 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
34279-34290
200 i = BIO_read(in, &(b->data[len]), chunk);-
201 if (i <= 0
i <= 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 34280 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
10-34280
202 ERR_put_error(13,(107),(142),__FILE__,198)-
203 ;-
204 goto
executed 10 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
err;
executed 10 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
10
205 }-
206-
207-
208-
209-
210 len += i;-
211 chunk -= i;-
212 }
executed 34280 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
34280
213 if (chunk_max < 0x7fffffff/2
chunk_max < 0x7fffffff/2Description
TRUEevaluated 34279 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-34279
214 chunk_max *= 2;
executed 34279 times by 1 test: chunk_max *= 2;
Executed by:
  • libcrypto.so.1.1
34279
215 }
executed 34279 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
34279
216 }
executed 34273 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
34273
217 if (off + slen < off
off + slen < offDescription
TRUEnever evaluated
FALSEevaluated 224987 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-224987
218 ERR_put_error(13,(107),(155),__FILE__,213);-
219 goto
never executed: goto err;
err;
never executed: goto err;
0
220 }-
221 off += slen;-
222 if (eos == 0
eos == 0Description
TRUEevaluated 354 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 224633 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
354-224633
223 break;
executed 354 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
354
224 } else-
225 want = 8;
executed 224633 times by 1 test: want = 8;
Executed by:
  • libcrypto.so.1.1
224633
226 }-
227 }-
228-
229 if (off > 0x7fffffff
off > 0x7fffffffDescription
TRUEnever evaluated
FALSEevaluated 1540 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-1540
230 ERR_put_error(13,(107),(155),__FILE__,225);-
231 goto
never executed: goto err;
err;
never executed: goto err;
0
232 }-
233-
234 *pb = b;-
235 return
executed 1540 times by 1 test: return off;
Executed by:
  • libcrypto.so.1.1
off;
executed 1540 times by 1 test: return off;
Executed by:
  • libcrypto.so.1.1
1540
236 err:-
237 BUF_MEM_free(b);-
238 return
executed 14 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
-1;
executed 14 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
14
239}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2