OpenCoverage

conf_mod.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/conf/conf_mod.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.-
3 *-
4 * Licensed under the OpenSSL license (the "License"). You may not use-
5 * this file except in compliance with the License. You can obtain a copy-
6 * in the file LICENSE in the source distribution or at-
7 * https://www.openssl.org/source/license.html-
8 */-
9-
10#include "internal/cryptlib.h"-
11#include <stdio.h>-
12#include <ctype.h>-
13#include <openssl/crypto.h>-
14#include "internal/conf.h"-
15#include "internal/dso.h"-
16#include <openssl/x509.h>-
17-
18#define DSO_mod_init_name "OPENSSL_init"-
19#define DSO_mod_finish_name "OPENSSL_finish"-
20-
21/*-
22 * This structure contains a data about supported modules. entries in this-
23 * table correspond to either dynamic or static modules.-
24 */-
25-
26struct conf_module_st {-
27 /* DSO of this module or NULL if static */-
28 DSO *dso;-
29 /* Name of the module */-
30 char *name;-
31 /* Init function */-
32 conf_init_func *init;-
33 /* Finish function */-
34 conf_finish_func *finish;-
35 /* Number of successfully initialized modules */-
36 int links;-
37 void *usr_data;-
38};-
39-
40/*-
41 * This structure contains information about modules that have been-
42 * successfully initialized. There may be more than one entry for a given-
43 * module.-
44 */-
45-
46struct conf_imodule_st {-
47 CONF_MODULE *pmod;-
48 char *name;-
49 char *value;-
50 unsigned long flags;-
51 void *usr_data;-
52};-
53-
54static STACK_OF(CONF_MODULE) *supported_modules = NULL;-
55static STACK_OF(CONF_IMODULE) *initialized_modules = NULL;-
56-
57static void module_free(CONF_MODULE *md);-
58static void module_finish(CONF_IMODULE *imod);-
59static int module_run(const CONF *cnf, const char *name, const char *value,-
60 unsigned long flags);-
61static CONF_MODULE *module_add(DSO *dso, const char *name,-
62 conf_init_func *ifunc,-
63 conf_finish_func *ffunc);-
64static CONF_MODULE *module_find(const char *name);-
65static int module_init(CONF_MODULE *pmod, const char *name, const char *value,-
66 const CONF *cnf);-
67static CONF_MODULE *module_load_dso(const CONF *cnf, const char *name,-
68 const char *value);-
69-
70/* Main function: load modules from a CONF structure */-
71-
72int CONF_modules_load(const CONF *cnf, const char *appname,-
73 unsigned long flags)-
74{-
75 STACK_OF(CONF_VALUE) *values;-
76 CONF_VALUE *vl;-
77 char *vsection = NULL;-
78-
79 int ret, i;-
80-
81 if (!cnf)
!cnfDescription
TRUEnever evaluated
FALSEevaluated 1140 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1140
82 return 1;
never executed: return 1;
0
83-
84 if (appname)
appnameDescription
TRUEevaluated 1109 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 31 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
31-1109
85 vsection = NCONF_get_string(cnf, NULL, appname);
executed 1109 times by 1 test: vsection = NCONF_get_string(cnf, ((void *)0) , appname);
Executed by:
  • libcrypto.so.1.1
1109
86-
87 if (!appname || (!vsection && (flags & CONF_MFLAGS_DEFAULT_SECTION)))
!appnameDescription
TRUEevaluated 31 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1109 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!vsectionDescription
TRUEnever evaluated
FALSEevaluated 1109 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(flags & 0x20)Description
TRUEnever evaluated
FALSEnever evaluated
0-1109
88 vsection = NCONF_get_string(cnf, NULL, "openssl_conf");
executed 31 times by 1 test: vsection = NCONF_get_string(cnf, ((void *)0) , "openssl_conf");
Executed by:
  • libcrypto.so.1.1
31
89-
90 if (!vsection) {
!vsectionDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
30-1110
91 ERR_clear_error();-
92 return 1;
executed 30 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
30
93 }-
94-
95 values = NCONF_get_section(cnf, vsection);-
96-
97 if (!values)
!valuesDescription
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1110
98 return 0;
never executed: return 0;
0
99-
100 for (i = 0; i < sk_CONF_VALUE_num(values); i++) {
i < sk_CONF_VALUE_num(values)Description
TRUEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1110
101 vl = sk_CONF_VALUE_value(values, i);-
102 ret = module_run(cnf, vl->name, vl->value, flags);-
103 if (ret <= 0)
ret <= 0Description
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1110
104 if (!(flags & CONF_MFLAGS_IGNORE_ERRORS))
!(flags & 0x1)Description
TRUEnever evaluated
FALSEnever evaluated
0
105 return ret;
never executed: return ret;
0
106 }
executed 1110 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1110
107-
108 return 1;
executed 1110 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1110
109-
110}-
111-
112int CONF_modules_load_file(const char *filename, const char *appname,-
113 unsigned long flags)-
114{-
115 char *file = NULL;-
116 CONF *conf = NULL;-
117 int ret = 0;-
118 conf = NCONF_new(NULL);-
119 if (conf == NULL)
conf == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1958 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1958
120 goto err;
never executed: goto err;
0
121-
122 if (filename == NULL) {
filename == ((void *)0)Description
TRUEevaluated 1958 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-1958
123 file = CONF_get1_default_config_file();-
124 if (!file)
!fileDescription
TRUEnever evaluated
FALSEevaluated 1958 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1958
125 goto err;
never executed: goto err;
0
126 } else
executed 1958 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1958
127 file = (char *)filename;
never executed: file = (char *)filename;
0
128-
129 if (NCONF_load(conf, file, NULL) <= 0) {
NCONF_load(con...id *)0) ) <= 0Description
TRUEevaluated 1957 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-1957
130 if ((flags & CONF_MFLAGS_IGNORE_MISSING_FILE) &&
(flags & 0x10)Description
TRUEevaluated 1957 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-1957
131 (ERR_GET_REASON(ERR_peek_last_error()) == CONF_R_NO_SUCH_FILE)) {
((int)( (ERR_p...xFFFL) == 114)Description
TRUEevaluated 1957 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-1957
132 ERR_clear_error();-
133 ret = 1;-
134 }
executed 1957 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1957
135 goto err;
executed 1957 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
1957
136 }-
137-
138 ret = CONF_modules_load(conf, appname, flags);-
139-
140 err:
code before this statement executed 1 time by 1 test: err:
Executed by:
  • libcrypto.so.1.1
1
141 if (filename == NULL)
filename == ((void *)0)Description
TRUEevaluated 1958 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-1958
142 OPENSSL_free(file);
executed 1958 times by 1 test: CRYPTO_free(file, __FILE__, 142);
Executed by:
  • libcrypto.so.1.1
1958
143 NCONF_free(conf);-
144-
145 return ret;
executed 1958 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
1958
146}-
147-
148static int module_run(const CONF *cnf, const char *name, const char *value,-
149 unsigned long flags)-
150{-
151 CONF_MODULE *md;-
152 int ret;-
153-
154 md = module_find(name);-
155-
156 /* Module not found: try to load DSO */-
157 if (!md && !(flags & CONF_MFLAGS_NO_DSO))
!mdDescription
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!(flags & 0x8)Description
TRUEnever evaluated
FALSEnever evaluated
0-1110
158 md = module_load_dso(cnf, name, value);
never executed: md = module_load_dso(cnf, name, value);
0
159-
160 if (!md) {
!mdDescription
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1110
161 if (!(flags & CONF_MFLAGS_SILENT)) {
!(flags & 0x4)Description
TRUEnever evaluated
FALSEnever evaluated
0
162 CONFerr(CONF_F_MODULE_RUN, CONF_R_UNKNOWN_MODULE_NAME);-
163 ERR_add_error_data(2, "module=", name);-
164 }
never executed: end of block
0
165 return -1;
never executed: return -1;
0
166 }-
167-
168 ret = module_init(md, name, value, cnf);-
169-
170 if (ret <= 0) {
ret <= 0Description
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1110
171 if (!(flags & CONF_MFLAGS_SILENT)) {
!(flags & 0x4)Description
TRUEnever evaluated
FALSEnever evaluated
0
172 char rcode[DECIMAL_SIZE(ret) + 1];-
173-
174 CONFerr(CONF_F_MODULE_RUN, CONF_R_MODULE_INITIALIZATION_ERROR);-
175 BIO_snprintf(rcode, sizeof(rcode), "%-8d", ret);-
176 ERR_add_error_data(6, "module=", name, ", value=", value,-
177 ", retcode=", rcode);-
178 }
never executed: end of block
0
179 }
never executed: end of block
0
180-
181 return ret;
executed 1110 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
1110
182}-
183-
184/* Load a module from a DSO */-
185static CONF_MODULE *module_load_dso(const CONF *cnf,-
186 const char *name, const char *value)-
187{-
188 DSO *dso = NULL;-
189 conf_init_func *ifunc;-
190 conf_finish_func *ffunc;-
191 const char *path = NULL;-
192 int errcode = 0;-
193 CONF_MODULE *md;-
194 /* Look for alternative path in module section */-
195 path = NCONF_get_string(cnf, value, "path");-
196 if (!path) {
!pathDescription
TRUEnever evaluated
FALSEnever evaluated
0
197 ERR_clear_error();-
198 path = name;-
199 }
never executed: end of block
0
200 dso = DSO_load(NULL, path, NULL, 0);-
201 if (!dso) {
!dsoDescription
TRUEnever evaluated
FALSEnever evaluated
0
202 errcode = CONF_R_ERROR_LOADING_DSO;-
203 goto err;
never executed: goto err;
0
204 }-
205 ifunc = (conf_init_func *)DSO_bind_func(dso, DSO_mod_init_name);-
206 if (!ifunc) {
!ifuncDescription
TRUEnever evaluated
FALSEnever evaluated
0
207 errcode = CONF_R_MISSING_INIT_FUNCTION;-
208 goto err;
never executed: goto err;
0
209 }-
210 ffunc = (conf_finish_func *)DSO_bind_func(dso, DSO_mod_finish_name);-
211 /* All OK, add module */-
212 md = module_add(dso, name, ifunc, ffunc);-
213-
214 if (!md)
!mdDescription
TRUEnever evaluated
FALSEnever evaluated
0
215 goto err;
never executed: goto err;
0
216-
217 return md;
never executed: return md;
0
218-
219 err:-
220 DSO_free(dso);-
221 CONFerr(CONF_F_MODULE_LOAD_DSO, errcode);-
222 ERR_add_error_data(4, "module=", name, ", path=", path);-
223 return NULL;
never executed: return ((void *)0) ;
0
224}-
225-
226/* add module to list */-
227static CONF_MODULE *module_add(DSO *dso, const char *name,-
228 conf_init_func *ifunc, conf_finish_func *ffunc)-
229{-
230 CONF_MODULE *tmod = NULL;-
231 if (supported_modules == NULL)
supported_modu...== ((void *)0)Description
TRUEevaluated 1958 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7832 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1958-7832
232 supported_modules = sk_CONF_MODULE_new_null();
executed 1958 times by 1 test: supported_modules = sk_CONF_MODULE_new_null();
Executed by:
  • libcrypto.so.1.1
1958
233 if (supported_modules == NULL)
supported_modu...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 9790 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-9790
234 return NULL;
never executed: return ((void *)0) ;
0
235 if ((tmod = OPENSSL_zalloc(sizeof(*tmod))) == NULL) {
(tmod = CRYPTO...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 9790 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-9790
236 CONFerr(CONF_F_MODULE_ADD, ERR_R_MALLOC_FAILURE);-
237 return NULL;
never executed: return ((void *)0) ;
0
238 }-
239-
240 tmod->dso = dso;-
241 tmod->name = OPENSSL_strdup(name);-
242 tmod->init = ifunc;-
243 tmod->finish = ffunc;-
244 if (tmod->name == NULL) {
tmod->name == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 9790 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-9790
245 OPENSSL_free(tmod);-
246 return NULL;
never executed: return ((void *)0) ;
0
247 }-
248-
249 if (!sk_CONF_MODULE_push(supported_modules, tmod)) {
!sk_CONF_MODUL...modules, tmod)Description
TRUEnever evaluated
FALSEevaluated 9790 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-9790
250 OPENSSL_free(tmod->name);-
251 OPENSSL_free(tmod);-
252 return NULL;
never executed: return ((void *)0) ;
0
253 }-
254-
255 return tmod;
executed 9790 times by 1 test: return tmod;
Executed by:
  • libcrypto.so.1.1
9790
256}-
257-
258/*-
259 * Find a module from the list. We allow module names of the form-
260 * modname.XXXX to just search for modname to allow the same module to be-
261 * initialized more than once.-
262 */-
263-
264static CONF_MODULE *module_find(const char *name)-
265{-
266 CONF_MODULE *tmod;-
267 int i, nchar;-
268 char *p;-
269 p = strrchr(name, '.');-
270-
271 if (p)
pDescription
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1110
272 nchar = p - name;
never executed: nchar = p - name;
0
273 else-
274 nchar = strlen(name);
executed 1110 times by 1 test: nchar = strlen(name);
Executed by:
  • libcrypto.so.1.1
1110
275-
276 for (i = 0; i < sk_CONF_MODULE_num(supported_modules); i++) {
i < sk_CONF_MO...orted_modules)Description
TRUEevaluated 5550 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-5550
277 tmod = sk_CONF_MODULE_value(supported_modules, i);-
278 if (strncmp(tmod->name, name, nchar) == 0)
never executed: __result = (((const unsigned char *) (const char *) ( tmod->name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(__extension__...nchar ))) == 0Description
TRUEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4440 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
__builtin_constant_p ( nchar )Description
TRUEnever evaluated
FALSEevaluated 5550 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
__builtin_cons...( tmod->name )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( tmod-..._t) ( nchar ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( name )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( name ..._t) ( nchar ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-5550
279 return tmod;
executed 1110 times by 1 test: return tmod;
Executed by:
  • libcrypto.so.1.1
1110
280 }
executed 4440 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4440
281-
282 return NULL;
never executed: return ((void *)0) ;
0
283-
284}-
285-
286/* initialize a module */-
287static int module_init(CONF_MODULE *pmod, const char *name, const char *value,-
288 const CONF *cnf)-
289{-
290 int ret = 1;-
291 int init_called = 0;-
292 CONF_IMODULE *imod = NULL;-
293-
294 /* Otherwise add initialized module to list */-
295 imod = OPENSSL_malloc(sizeof(*imod));-
296 if (imod == NULL)
imod == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1110
297 goto err;
never executed: goto err;
0
298-
299 imod->pmod = pmod;-
300 imod->name = OPENSSL_strdup(name);-
301 imod->value = OPENSSL_strdup(value);-
302 imod->usr_data = NULL;-
303-
304 if (!imod->name || !imod->value)
!imod->nameDescription
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!imod->valueDescription
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1110
305 goto memerr;
never executed: goto memerr;
0
306-
307 /* Try to initialize module */-
308 if (pmod->init) {
pmod->initDescription
TRUEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-1110
309 ret = pmod->init(imod, cnf);-
310 init_called = 1;-
311 /* Error occurred, exit */-
312 if (ret <= 0)
ret <= 0Description
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1110
313 goto err;
never executed: goto err;
0
314 }
executed 1110 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1110
315-
316 if (initialized_modules == NULL) {
initialized_mo...== ((void *)0)Description
TRUEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-1110
317 initialized_modules = sk_CONF_IMODULE_new_null();-
318 if (!initialized_modules) {
!initialized_modulesDescription
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1110
319 CONFerr(CONF_F_MODULE_INIT, ERR_R_MALLOC_FAILURE);-
320 goto err;
never executed: goto err;
0
321 }-
322 }
executed 1110 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1110
323-
324 if (!sk_CONF_IMODULE_push(initialized_modules, imod)) {
!sk_CONF_IMODU...modules, imod)Description
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1110
325 CONFerr(CONF_F_MODULE_INIT, ERR_R_MALLOC_FAILURE);-
326 goto err;
never executed: goto err;
0
327 }-
328-
329 pmod->links++;-
330-
331 return ret;
executed 1110 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
1110
332-
333 err:-
334-
335 /* We've started the module so we'd better finish it */-
336 if (pmod->finish && init_called)
pmod->finishDescription
TRUEnever evaluated
FALSEnever evaluated
init_calledDescription
TRUEnever evaluated
FALSEnever evaluated
0
337 pmod->finish(imod);
never executed: pmod->finish(imod);
0
338-
339 memerr:
code before this statement never executed: memerr:
0
340 if (imod) {
imodDescription
TRUEnever evaluated
FALSEnever evaluated
0
341 OPENSSL_free(imod->name);-
342 OPENSSL_free(imod->value);-
343 OPENSSL_free(imod);-
344 }
never executed: end of block
0
345-
346 return -1;
never executed: return -1;
0
347-
348}-
349-
350/*-
351 * Unload any dynamic modules that have a link count of zero: i.e. have no-
352 * active initialized modules. If 'all' is set then all modules are unloaded-
353 * including static ones.-
354 */-
355-
356void CONF_modules_unload(int all)-
357{-
358 int i;-
359 CONF_MODULE *md;-
360 CONF_modules_finish();-
361 /* unload modules in reverse order */-
362 for (i = sk_CONF_MODULE_num(supported_modules) - 1; i >= 0; i--) {
i >= 0Description
TRUEevaluated 15335 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3185 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
3185-15335
363 md = sk_CONF_MODULE_value(supported_modules, i);-
364 /* If static or in use and 'all' not set ignore it */-
365 if (((md->links > 0) || !md->dso) && !all)
(md->links > 0)Description
TRUEnever evaluated
FALSEevaluated 15335 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!md->dsoDescription
TRUEevaluated 15335 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
!allDescription
TRUEevaluated 5545 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 9790 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-15335
366 continue;
executed 5545 times by 1 test: continue;
Executed by:
  • libcrypto.so.1.1
5545
367 /* Since we're working in reverse this is OK */-
368 (void)sk_CONF_MODULE_delete(supported_modules, i);-
369 module_free(md);-
370 }
executed 9790 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
9790
371 if (sk_CONF_MODULE_num(supported_modules) == 0) {
sk_CONF_MODULE..._modules) == 0Description
TRUEevaluated 1958 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1227 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
1227-1958
372 sk_CONF_MODULE_free(supported_modules);-
373 supported_modules = NULL;-
374 }
executed 1958 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1958
375}
executed 3185 times by 12 tests: end of block
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
3185
376-
377/* unload a single module */-
378static void module_free(CONF_MODULE *md)-
379{-
380 DSO_free(md->dso);-
381 OPENSSL_free(md->name);-
382 OPENSSL_free(md);-
383}
executed 9790 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
9790
384-
385/* finish and free up all modules instances */-
386-
387void CONF_modules_finish(void)-
388{-
389 CONF_IMODULE *imod;-
390 while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
sk_CONF_IMODUL...d_modules) > 0Description
TRUEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5261 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
1110-5261
391 imod = sk_CONF_IMODULE_pop(initialized_modules);-
392 module_finish(imod);-
393 }
executed 1110 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1110
394 sk_CONF_IMODULE_free(initialized_modules);-
395 initialized_modules = NULL;-
396}
executed 5261 times by 12 tests: end of block
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
5261
397-
398/* finish a module instance */-
399-
400static void module_finish(CONF_IMODULE *imod)-
401{-
402 if (!imod)
!imodDescription
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1110
403 return;
never executed: return;
0
404 if (imod->pmod->finish)
imod->pmod->finishDescription
TRUEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-1110
405 imod->pmod->finish(imod);
executed 1110 times by 1 test: imod->pmod->finish(imod);
Executed by:
  • libcrypto.so.1.1
1110
406 imod->pmod->links--;-
407 OPENSSL_free(imod->name);-
408 OPENSSL_free(imod->value);-
409 OPENSSL_free(imod);-
410}
executed 1110 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1110
411-
412/* Add a static module to OpenSSL */-
413-
414int CONF_module_add(const char *name, conf_init_func *ifunc,-
415 conf_finish_func *ffunc)-
416{-
417 if (module_add(NULL, name, ifunc, ffunc))
module_add( ((... ifunc, ffunc)Description
TRUEevaluated 9790 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-9790
418 return 1;
executed 9790 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
9790
419 else-
420 return 0;
never executed: return 0;
0
421}-
422-
423void conf_modules_free_int(void)-
424{-
425 CONF_modules_finish();-
426 CONF_modules_unload(1);-
427}
executed 2076 times by 12 tests: end of block
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
2076
428-
429/* Utility functions */-
430-
431const char *CONF_imodule_get_name(const CONF_IMODULE *md)-
432{-
433 return md->name;
never executed: return md->name;
0
434}-
435-
436const char *CONF_imodule_get_value(const CONF_IMODULE *md)-
437{-
438 return md->value;
executed 1110 times by 1 test: return md->value;
Executed by:
  • libcrypto.so.1.1
1110
439}-
440-
441void *CONF_imodule_get_usr_data(const CONF_IMODULE *md)-
442{-
443 return md->usr_data;
never executed: return md->usr_data;
0
444}-
445-
446void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data)-
447{-
448 md->usr_data = usr_data;-
449}
never executed: end of block
0
450-
451CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md)-
452{-
453 return md->pmod;
never executed: return md->pmod;
0
454}-
455-
456unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md)-
457{-
458 return md->flags;
never executed: return md->flags;
0
459}-
460-
461void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags)-
462{-
463 md->flags = flags;-
464}
never executed: end of block
0
465-
466void *CONF_module_get_usr_data(CONF_MODULE *pmod)-
467{-
468 return pmod->usr_data;
never executed: return pmod->usr_data;
0
469}-
470-
471void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data)-
472{-
473 pmod->usr_data = usr_data;-
474}
never executed: end of block
0
475-
476/* Return default config file name */-
477-
478char *CONF_get1_default_config_file(void)-
479{-
480 char *file, *sep = "";-
481 int len;-
482-
483 if (!OPENSSL_issetugid()) {
!OPENSSL_issetugid()Description
TRUEevaluated 1958 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-1958
484 file = getenv("OPENSSL_CONF");-
485 if (file)
fileDescription
TRUEevaluated 1958 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-1958
486 return OPENSSL_strdup(file);
executed 1958 times by 1 test: return CRYPTO_strdup(file, __FILE__, 486);
Executed by:
  • libcrypto.so.1.1
1958
487 }
never executed: end of block
0
488-
489 len = strlen(X509_get_default_cert_area());-
490#ifndef OPENSSL_SYS_VMS-
491 len++;-
492 sep = "/";-
493#endif-
494 len += strlen(OPENSSL_CONF);-
495-
496 file = OPENSSL_malloc(len + 1);-
497-
498 if (file == NULL)
file == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
499 return NULL;
never executed: return ((void *)0) ;
0
500 BIO_snprintf(file, len + 1, "%s%s%s", X509_get_default_cert_area(),-
501 sep, OPENSSL_CONF);-
502-
503 return file;
never executed: return file;
0
504}-
505-
506/*-
507 * This function takes a list separated by 'sep' and calls the callback-
508 * function giving the start and length of each member optionally stripping-
509 * leading and trailing whitespace. This can be used to parse comma separated-
510 * lists for example.-
511 */-
512-
513int CONF_parse_list(const char *list_, int sep, int nospc,-
514 int (*list_cb) (const char *elem, int len, void *usr),-
515 void *arg)-
516{-
517 int ret;-
518 const char *lstart, *tmpend, *p;-
519-
520 if (list_ == NULL) {
list_ == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 11572 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-11572
521 CONFerr(CONF_F_CONF_PARSE_LIST, CONF_R_LIST_CANNOT_BE_NULL);-
522 return 0;
never executed: return 0;
0
523 }-
524-
525 lstart = list_;-
526 for (;;) {-
527 if (nospc) {
nospcDescription
TRUEevaluated 40713 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-40713
528 while (*lstart && isspace((unsigned char)*lstart))
*lstartDescription
TRUEevaluated 40713 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEevaluated 40713 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-40713
529 lstart++;
never executed: lstart++;
0
530 }
executed 40713 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
40713
531 p = strchr(lstart, sep);
__builtin_constant_p ( sep )Description
TRUEnever evaluated
FALSEevaluated 40713 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!__builtin_con...t_p ( lstart )Description
TRUEnever evaluated
FALSEnever evaluated
( sep ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0-40713
532 if (p == lstart || !*lstart)
p == lstartDescription
TRUEnever evaluated
FALSEevaluated 40713 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!*lstartDescription
TRUEnever evaluated
FALSEevaluated 40713 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-40713
533 ret = list_cb(NULL, 0, arg);
never executed: ret = list_cb( ((void *)0) , 0, arg);
0
534 else {-
535 if (p)
pDescription
TRUEevaluated 29141 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11572 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
11572-29141
536 tmpend = p - 1;
executed 29141 times by 1 test: tmpend = p - 1;
Executed by:
  • libcrypto.so.1.1
29141
537 else-
538 tmpend = lstart + strlen(lstart) - 1;
executed 11572 times by 1 test: tmpend = lstart + strlen(lstart) - 1;
Executed by:
  • libcrypto.so.1.1
11572
539 if (nospc) {
nospcDescription
TRUEevaluated 40713 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-40713
540 while (isspace((unsigned char)*tmpend))
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEevaluated 40713 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-40713
541 tmpend--;
never executed: tmpend--;
0
542 }
executed 40713 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
40713
543 ret = list_cb(lstart, tmpend - lstart + 1, arg);-
544 }
executed 40713 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
40713
545 if (ret <= 0)
ret <= 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 40705 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
8-40705
546 return ret;
executed 8 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
8
547 if (p == NULL)
p == ((void *)0)Description
TRUEevaluated 11564 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 29141 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
11564-29141
548 return 1;
executed 11564 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
11564
549 lstart = p + 1;-
550 }
executed 29141 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
29141
551}
never executed: end of block
0
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2