OpenCoverage

by_file.c

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

Generated by Squish Coco 4.2.2