OpenCoverage

by_file.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/x509/by_file.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,-
6 long argl, char **ret);-
7-
8static X509_LOOKUP_METHOD x509_file_lookup = {-
9 .name = "Load file into cache",-
10 .new_item = -
11 ((void *)0)-
12 ,-
13 .free = -
14 ((void *)0)-
15 ,-
16 .init = -
17 ((void *)0)-
18 ,-
19 .shutdown = -
20 ((void *)0)-
21 ,-
22 .ctrl = by_file_ctrl,-
23 .get_by_subject = -
24 ((void *)0)-
25 ,-
26 .get_by_issuer_serial = -
27 ((void *)0)-
28 ,-
29 .get_by_fingerprint = -
30 ((void *)0)-
31 ,-
32 .get_by_alias = -
33 ((void *)0)-
34 ,-
35};-
36-
37X509_LOOKUP_METHOD *-
38X509_LOOKUP_file(void)-
39{-
40 return
executed 43 times by 2 tests: return (&x509_file_lookup);
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
(&x509_file_lookup);
executed 43 times by 2 tests: return (&x509_file_lookup);
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
43
41}-
42-
43static int-
44by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,-
45 char **ret)-
46{-
47 int ok = 0;-
48-
49 switch (cmd) {-
50 case
executed 43 times by 2 tests: case 1:
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
1:
executed 43 times by 2 tests: case 1:
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
43
51 if (argl == 3
argl == 3Description
TRUEevaluated 23 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • ssltest
FALSEevaluated 20 times by 1 test
Evaluated by:
  • ssltest
) {
20-23
52 ok = (X509_load_cert_crl_file(ctx,-
53 X509_get_default_cert_file(),-
54 1) != 0);-
55 if (!ok
!okDescription
TRUEevaluated 23 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • ssltest
FALSEnever evaluated
) {
0-23
56 ERR_put_error(11,(0xfff),(104),__FILE__,105);-
57 }
executed 23 times by 2 tests: end of block
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
23
58 }
executed 23 times by 2 tests: end of block
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
else {
23
59 if (argl == 1
argl == 1Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • ssltest
FALSEnever evaluated
)
0-20
60 ok = (X509_load_cert_crl_file(ctx, argp,
executed 20 times by 1 test: ok = (X509_load_cert_crl_file(ctx, argp, 1) != 0);
Executed by:
  • ssltest
20
61 1) != 0);
executed 20 times by 1 test: ok = (X509_load_cert_crl_file(ctx, argp, 1) != 0);
Executed by:
  • ssltest
20
62 else-
63 ok = (X509_load_cert_file(ctx,
never executed: ok = (X509_load_cert_file(ctx, argp, (int)argl) != 0);
0
64 argp, (int)argl) != 0);
never executed: ok = (X509_load_cert_file(ctx, argp, (int)argl) != 0);
0
65 }-
66 break;
executed 43 times by 2 tests: break;
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
43
67 }-
68 return
executed 43 times by 2 tests: return (ok);
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
(ok);
executed 43 times by 2 tests: return (ok);
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
43
69}-
70-
71int-
72X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type)-
73{-
74 int ret = 0;-
75 BIO *in = -
76 ((void *)0)-
77 ;-
78 int i, count = 0;-
79 X509 *x = -
80 ((void *)0)-
81 ;-
82-
83 if (file ==
file == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
84 ((void *)0)
file == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
85 )-
86 return
never executed: return (1);
(1);
never executed: return (1);
0
87 in = BIO_new(BIO_s_file());-
88-
89 if ((
(in == ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
in ==
(in == ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
90 ((void *)0)
(in == ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
91 )
(in == ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(BIO_ctrl(in,1... *)file) <= 0)Description
TRUEnever evaluated
FALSEnever evaluated
BIO_ctrl(in,108, 0x01|0x02,(char *)file) <= 0)
(BIO_ctrl(in,1... *)file) <= 0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
92 ERR_put_error(11,(0xfff),(2),__FILE__,133);-
93 goto
never executed: goto err;
err;
never executed: goto err;
0
94 }-
95-
96 if (type == 1
type == 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
97 for (;;) {-
98 x = PEM_read_bio_X509_AUX(in, -
99 ((void *)0)-
100 , -
101 ((void *)0)-
102 , -
103 ((void *)0)-
104 );-
105 if (x ==
x == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
106 ((void *)0)
x == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
107 ) {-
108 if (((
((int)((ERR_pe...xfffL) == 108)Description
TRUEnever evaluated
FALSEnever evaluated
int)((ERR_peek_last_error())&0xfffL) ==
((int)((ERR_pe...xfffL) == 108)Description
TRUEnever evaluated
FALSEnever evaluated
0
109 108)
((int)((ERR_pe...xfffL) == 108)Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(count > 0)Description
TRUEnever evaluated
FALSEnever evaluated
count > 0)
(count > 0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
110 ERR_clear_error();-
111 break;
never executed: break;
0
112 } else {-
113 ERR_put_error(11,(0xfff),(9),__FILE__,146);-
114 goto
never executed: goto err;
err;
never executed: goto err;
0
115 }-
116 }-
117 i = X509_STORE_add_cert(ctx->store_ctx, x);-
118 if (!i
!iDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
119 goto
never executed: goto err;
err;
never executed: goto err;
0
120 count++;-
121 X509_free(x);-
122 x = -
123 ((void *)0)-
124 ;-
125 }
never executed: end of block
0
126 ret = count;-
127 }
never executed: end of block
else if (type == 2
type == 2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
128 x = d2i_X509_bio(in, -
129 ((void *)0)-
130 );-
131 if (x ==
x == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
132 ((void *)0)
x == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
133 ) {-
134 ERR_put_error(11,(0xfff),(13),__FILE__,161);-
135 goto
never executed: goto err;
err;
never executed: goto err;
0
136 }-
137 i = X509_STORE_add_cert(ctx->store_ctx, x);-
138 if (!i
!iDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
139 goto
never executed: goto err;
err;
never executed: goto err;
0
140 ret = i;-
141 }
never executed: end of block
else {
0
142 ERR_put_error(11,(0xfff),(100),__FILE__,169);-
143 goto
never executed: goto err;
err;
never executed: goto err;
0
144 }-
145err:
code before this statement never executed: err:
0
146 X509_free(x);-
147 BIO_free(in);-
148 return
never executed: return (ret);
(ret);
never executed: return (ret);
0
149}-
150-
151int-
152X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type)-
153{-
154 int ret = 0;-
155 BIO *in = -
156 ((void *)0)-
157 ;-
158 int i, count = 0;-
159 X509_CRL *x = -
160 ((void *)0)-
161 ;-
162-
163 if (file ==
file == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
164 ((void *)0)
file == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
165 )-
166 return
never executed: return (1);
(1);
never executed: return (1);
0
167 in = BIO_new(BIO_s_file());-
168-
169 if ((
(in == ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
in ==
(in == ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
170 ((void *)0)
(in == ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
171 )
(in == ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(BIO_ctrl(in,1... *)file) <= 0)Description
TRUEnever evaluated
FALSEnever evaluated
BIO_ctrl(in,108, 0x01|0x02,(char *)file) <= 0)
(BIO_ctrl(in,1... *)file) <= 0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
172 ERR_put_error(11,(0xfff),(2),__FILE__,191);-
173 goto
never executed: goto err;
err;
never executed: goto err;
0
174 }-
175-
176 if (type == 1
type == 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
177 for (;;) {-
178 x = PEM_read_bio_X509_CRL(in, -
179 ((void *)0)-
180 , -
181 ((void *)0)-
182 , -
183 ((void *)0)-
184 );-
185 if (x ==
x == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
186 ((void *)0)
x == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
187 ) {-
188 if (((
((int)((ERR_pe...xfffL) == 108)Description
TRUEnever evaluated
FALSEnever evaluated
int)((ERR_peek_last_error())&0xfffL) ==
((int)((ERR_pe...xfffL) == 108)Description
TRUEnever evaluated
FALSEnever evaluated
0
189 108)
((int)((ERR_pe...xfffL) == 108)Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(count > 0)Description
TRUEnever evaluated
FALSEnever evaluated
count > 0)
(count > 0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
190 ERR_clear_error();-
191 break;
never executed: break;
0
192 } else {-
193 ERR_put_error(11,(0xfff),(9),__FILE__,204);-
194 goto
never executed: goto err;
err;
never executed: goto err;
0
195 }-
196 }-
197 i = X509_STORE_add_crl(ctx->store_ctx, x);-
198 if (!i
!iDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
199 goto
never executed: goto err;
err;
never executed: goto err;
0
200 count++;-
201 X509_CRL_free(x);-
202 x = -
203 ((void *)0)-
204 ;-
205 }
never executed: end of block
0
206 ret = count;-
207 }
never executed: end of block
else if (type == 2
type == 2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
208 x = d2i_X509_CRL_bio(in, -
209 ((void *)0)-
210 );-
211 if (x ==
x == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
212 ((void *)0)
x == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
213 ) {-
214 ERR_put_error(11,(0xfff),(13),__FILE__,219);-
215 goto
never executed: goto err;
err;
never executed: goto err;
0
216 }-
217 i = X509_STORE_add_crl(ctx->store_ctx, x);-
218 if (!i
!iDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
219 goto
never executed: goto err;
err;
never executed: goto err;
0
220 ret = i;-
221 }
never executed: end of block
else {
0
222 ERR_put_error(11,(0xfff),(100),__FILE__,227);-
223 goto
never executed: goto err;
err;
never executed: goto err;
0
224 }-
225err:
code before this statement never executed: err:
0
226 if (x !=
x != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
227 ((void *)0)
x != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
228 )-
229 X509_CRL_free(x);
never executed: X509_CRL_free(x);
0
230 BIO_free(in);-
231 return
never executed: return (ret);
(ret);
never executed: return (ret);
0
232}-
233-
234int-
235X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type)-
236{-
237 struct stack_st_X509_INFO *inf;-
238 X509_INFO *itmp;-
239 BIO *in;-
240 int i, count = 0;-
241 if (type != 1
type != 1Description
TRUEnever evaluated
FALSEevaluated 43 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • ssltest
)
0-43
242 return
never executed: return X509_load_cert_file(ctx, file, type);
X509_load_cert_file(ctx, file, type);
never executed: return X509_load_cert_file(ctx, file, type);
0
243 in = BIO_new_file(file, "r");-
244 if (!in
!inDescription
TRUEevaluated 23 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • ssltest
FALSEevaluated 20 times by 1 test
Evaluated by:
  • ssltest
) {
20-23
245 ERR_put_error(11,(0xfff),(2),__FILE__,248);-
246 return
executed 23 times by 2 tests: return 0;
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
0;
executed 23 times by 2 tests: return 0;
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
23
247 }-
248 inf = PEM_X509_INFO_read_bio(in, -
249 ((void *)0)-
250 , -
251 ((void *)0)-
252 , -
253 ((void *)0)-
254 );-
255 BIO_free(in);-
256 if (!inf
!infDescription
TRUEnever evaluated
FALSEevaluated 20 times by 1 test
Evaluated by:
  • ssltest
) {
0-20
257 ERR_put_error(11,(0xfff),(9),__FILE__,254);-
258 return
never executed: return 0;
0;
never executed: return 0;
0
259 }-
260 for (i = 0; i < sk_num(((_STACK*) (1 ? (inf) : (struct stack_st_X509_INFO*)0)))
i < sk_num(((_...509_INFO*)0)))Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • ssltest
FALSEevaluated 20 times by 1 test
Evaluated by:
  • ssltest
; i++) {
20-40
261 itmp = ((X509_INFO *)sk_value(((_STACK*) (1 ? (inf) : (struct stack_st_X509_INFO*)0)), (i)));-
262 if (itmp->x509
itmp->x509Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • ssltest
FALSEnever evaluated
) {
0-40
263 X509_STORE_add_cert(ctx->store_ctx, itmp->x509);-
264 count++;-
265 }
executed 40 times by 1 test: end of block
Executed by:
  • ssltest
40
266 if (itmp->crl
itmp->crlDescription
TRUEnever evaluated
FALSEevaluated 40 times by 1 test
Evaluated by:
  • ssltest
) {
0-40
267 X509_STORE_add_crl(ctx->store_ctx, itmp->crl);-
268 count++;-
269 }
never executed: end of block
0
270 }
executed 40 times by 1 test: end of block
Executed by:
  • ssltest
40
271 sk_pop_free(((_STACK*) (1 ? (inf) : (struct stack_st_X509_INFO*)0)), ((void (*)(void *)) ((1 ? (X509_INFO_free) : (void (*)(X509_INFO *))0))));-
272 return
executed 20 times by 1 test: return count;
Executed by:
  • ssltest
count;
executed 20 times by 1 test: return count;
Executed by:
  • ssltest
20
273}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2