OpenCoverage

conf_ssl.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/conf/conf_ssl.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2015-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 <stdio.h>-
11#include <string.h>-
12#include <openssl/conf.h>-
13#include <openssl/err.h>-
14#include "internal/sslconf.h"-
15#include "conf_lcl.h"-
16-
17/*-
18 * SSL library configuration module placeholder. We load it here but defer-
19 * all decisions about its contents to libssl.-
20 */-
21-
22struct ssl_conf_name_st {-
23 /* Name of this set of commands */-
24 char *name;-
25 /* List of commands */-
26 SSL_CONF_CMD *cmds;-
27 /* Number of commands */-
28 size_t cmd_count;-
29};-
30-
31struct ssl_conf_cmd_st {-
32 /* Command */-
33 char *cmd;-
34 /* Argument */-
35 char *arg;-
36};-
37-
38static struct ssl_conf_name_st *ssl_names;-
39static size_t ssl_names_count;-
40-
41static void ssl_module_free(CONF_IMODULE *md)-
42{-
43 size_t i, j;-
44 if (ssl_names == NULL)
ssl_names == ((void *)0)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
45 return;
executed 1110 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
1110
46 for (i = 0; i < ssl_names_count; i++) {
i < ssl_names_countDescription
TRUEevaluated 2455 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1110-2455
47 struct ssl_conf_name_st *tname = ssl_names + i;-
48-
49 OPENSSL_free(tname->name);-
50 for (j = 0; j < tname->cmd_count; j++) {
j < tname->cmd_countDescription
TRUEevaluated 10991 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2455 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2455-10991
51 OPENSSL_free(tname->cmds[j].cmd);-
52 OPENSSL_free(tname->cmds[j].arg);-
53 }
executed 10991 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
10991
54 OPENSSL_free(tname->cmds);-
55 }
executed 2455 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2455
56 OPENSSL_free(ssl_names);-
57 ssl_names = NULL;-
58 ssl_names_count = 0;-
59}
executed 1110 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1110
60-
61static int ssl_module_init(CONF_IMODULE *md, const CONF *cnf)-
62{-
63 size_t i, j, cnt;-
64 int rv = 0;-
65 const char *ssl_conf_section;-
66 STACK_OF(CONF_VALUE) *cmd_lists;-
67-
68 ssl_conf_section = CONF_imodule_get_value(md);-
69 cmd_lists = NCONF_get_section(cnf, ssl_conf_section);-
70 if (sk_CONF_VALUE_num(cmd_lists) <= 0) {
sk_CONF_VALUE_...md_lists) <= 0Description
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1110
71 if (cmd_lists == NULL)
cmd_lists == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
72 CONFerr(CONF_F_SSL_MODULE_INIT, CONF_R_SSL_SECTION_NOT_FOUND);
never executed: ERR_put_error(14,(123),(120),__FILE__,72);
0
73 else-
74 CONFerr(CONF_F_SSL_MODULE_INIT, CONF_R_SSL_SECTION_EMPTY);
never executed: ERR_put_error(14,(123),(119),__FILE__,74);
0
75 ERR_add_error_data(2, "section=", ssl_conf_section);-
76 goto err;
never executed: goto err;
0
77 }-
78 cnt = sk_CONF_VALUE_num(cmd_lists);-
79 ssl_module_free(md);-
80 ssl_names = OPENSSL_zalloc(sizeof(*ssl_names) * cnt);-
81 ssl_names_count = cnt;-
82 for (i = 0; i < ssl_names_count; i++) {
i < ssl_names_countDescription
TRUEevaluated 2455 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1110-2455
83 struct ssl_conf_name_st *ssl_name = ssl_names + i;-
84 CONF_VALUE *sect = sk_CONF_VALUE_value(cmd_lists, (int)i);-
85 STACK_OF(CONF_VALUE) *cmds = NCONF_get_section(cnf, sect->value);-
86-
87 if (sk_CONF_VALUE_num(cmds) <= 0) {
sk_CONF_VALUE_num(cmds) <= 0Description
TRUEnever evaluated
FALSEevaluated 2455 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2455
88 if (cmds == NULL)
cmds == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
89 CONFerr(CONF_F_SSL_MODULE_INIT,
never executed: ERR_put_error(14,(123),(118),__FILE__,90) ;
0
90 CONF_R_SSL_COMMAND_SECTION_NOT_FOUND);
never executed: ERR_put_error(14,(123),(118),__FILE__,90) ;
0
91 else-
92 CONFerr(CONF_F_SSL_MODULE_INIT,
never executed: ERR_put_error(14,(123),(117),__FILE__,93) ;
0
93 CONF_R_SSL_COMMAND_SECTION_EMPTY);
never executed: ERR_put_error(14,(123),(117),__FILE__,93) ;
0
94 ERR_add_error_data(4, "name=", sect->name, ", value=", sect->value);-
95 goto err;
never executed: goto err;
0
96 }-
97 ssl_name->name = OPENSSL_strdup(sect->name);-
98 if (ssl_name->name == NULL)
ssl_name->name == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2455 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2455
99 goto err;
never executed: goto err;
0
100 cnt = sk_CONF_VALUE_num(cmds);-
101 ssl_name->cmds = OPENSSL_zalloc(cnt * sizeof(struct ssl_conf_cmd_st));-
102 if (ssl_name->cmds == NULL)
ssl_name->cmds == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2455 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2455
103 goto err;
never executed: goto err;
0
104 ssl_name->cmd_count = cnt;-
105 for (j = 0; j < cnt; j++) {
j < cntDescription
TRUEevaluated 10991 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2455 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2455-10991
106 const char *name;-
107 CONF_VALUE *cmd_conf = sk_CONF_VALUE_value(cmds, (int)j);-
108 struct ssl_conf_cmd_st *cmd = ssl_name->cmds + j;-
109-
110 /* Skip any initial dot in name */-
111 name = strchr(cmd_conf->name, '.');
__builtin_constant_p ( '.' )Description
TRUEevaluated 10991 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
!__builtin_con...d_conf->name )Description
TRUEevaluated 10991 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
( '.' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 10991 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10991
112 if (name != NULL)
name != ((void *)0)Description
TRUEevaluated 194 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10797 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
194-10797
113 name++;
executed 194 times by 1 test: name++;
Executed by:
  • libcrypto.so.1.1
194
114 else-
115 name = cmd_conf->name;
executed 10797 times by 1 test: name = cmd_conf->name;
Executed by:
  • libcrypto.so.1.1
10797
116 cmd->cmd = OPENSSL_strdup(name);-
117 cmd->arg = OPENSSL_strdup(cmd_conf->value);-
118 if (cmd->cmd == NULL || cmd->arg == NULL)
cmd->cmd == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10991 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
cmd->arg == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10991 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10991
119 goto err;
never executed: goto err;
0
120 }
executed 10991 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
10991
121-
122 }
executed 2455 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2455
123 rv = 1;-
124 err:
code before this statement executed 1110 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
1110
125 if (rv == 0)
rv == 0Description
TRUEnever evaluated
FALSEevaluated 1110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1110
126 ssl_module_free(md);
never executed: ssl_module_free(md);
0
127 return rv;
executed 1110 times by 1 test: return rv;
Executed by:
  • libcrypto.so.1.1
1110
128}-
129-
130/*-
131 * Returns the set of commands with index |idx| previously searched for via-
132 * conf_ssl_name_find. Also stores the name of the set of commands in |*name|-
133 * and the number of commands in the set in |*cnt|.-
134 */-
135const SSL_CONF_CMD *conf_ssl_get(size_t idx, const char **name, size_t *cnt)-
136{-
137 *name = ssl_names[idx].name;-
138 *cnt = ssl_names[idx].cmd_count;-
139 return ssl_names[idx].cmds;
executed 2454 times by 1 test: return ssl_names[idx].cmds;
Executed by:
  • libcrypto.so.1.1
2454
140}-
141-
142/*-
143 * Search for the named set of commands given in |name|. On success return the-
144 * index for the command set in |*idx|.-
145 * Returns 1 on success or 0 on failure.-
146 */-
147int conf_ssl_name_find(const char *name, size_t *idx)-
148{-
149 size_t i;-
150 const struct ssl_conf_name_st *nm;-
151-
152 if (name == NULL)
name == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10470 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10470
153 return 0;
never executed: return 0;
0
154 for (i = 0, nm = ssl_names; i < ssl_names_count; i++, nm++) {
i < ssl_names_countDescription
TRUEevaluated 4134 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8016 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4134-8016
155 if (strcmp(nm->name, name) == 0) {
never executed: __result = (((const unsigned char *) (const char *) ( nm->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__ ... )))); }) == 0Description
TRUEevaluated 2454 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1680 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
__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-2454
156 *idx = i;-
157 return 1;
executed 2454 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
2454
158 }-
159 }
executed 1680 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1680
160 return 0;
executed 8016 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
8016
161}-
162-
163/*-
164 * Given a command set |cmd|, return details on the command at index |idx| which-
165 * must be less than the number of commands in the set (as returned by-
166 * conf_ssl_get). The name of the command will be returned in |*cmdstr| and the-
167 * argument is returned in |*arg|.-
168 */-
169void conf_ssl_get_cmd(const SSL_CONF_CMD *cmd, size_t idx, char **cmdstr,-
170 char **arg)-
171{-
172 *cmdstr = cmd[idx].cmd;-
173 *arg = cmd[idx].arg;-
174}
executed 10987 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
10987
175-
176void conf_add_ssl_module(void)-
177{-
178 CONF_module_add("ssl_conf", ssl_module_init, ssl_module_free);-
179}
executed 1958 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1958
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2