OpenCoverage

ex_data.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/ex_data.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* $OpenBSD: ex_data.c,v 1.20 2018/03/17 16:20:01 beck Exp $ */-
2-
3/*-
4 * Overhaul notes;-
5 *-
6 * This code is now *mostly* thread-safe. It is now easier to understand in what-
7 * ways it is safe and in what ways it is not, which is an improvement. Firstly,-
8 * all per-class stacks and index-counters for ex_data are stored in the same-
9 * global LHASH table (keyed by class). This hash table uses locking for all-
10 * access with the exception of CRYPTO_cleanup_all_ex_data(), which must only be-
11 * called when no other threads can possibly race against it (even if it was-
12 * locked, the race would mean it's possible the hash table might have been-
13 * recreated after the cleanup). As classes can only be added to the hash table,-
14 * and within each class, the stack of methods can only be incremented, the-
15 * locking mechanics are simpler than they would otherwise be. For example, the-
16 * new/dup/free ex_data functions will lock the hash table, copy the method-
17 * pointers it needs from the relevant class, then unlock the hash table before-
18 * actually applying those method pointers to the task of the new/dup/free-
19 * operations. As they can't be removed from the method-stack, only-
20 * supplemented, there's no race conditions associated with using them outside-
21 * the lock. The get/set_ex_data functions are not locked because they do not-
22 * involve this global state at all - they operate directly with a previously-
23 * obtained per-class method index and a particular "ex_data" variable. These-
24 * variables are usually instantiated per-context (eg. each RSA structure has-
25 * one) so locking on read/write access to that variable can be locked locally-
26 * if required (eg. using the "RSA" lock to synchronise access to a-
27 * per-RSA-structure ex_data variable if required).-
28 * [Geoff]-
29 */-
30-
31/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)-
32 * All rights reserved.-
33 *-
34 * This package is an SSL implementation written-
35 * by Eric Young (eay@cryptsoft.com).-
36 * The implementation was written so as to conform with Netscapes SSL.-
37 *-
38 * This library is free for commercial and non-commercial use as long as-
39 * the following conditions are aheared to. The following conditions-
40 * apply to all code found in this distribution, be it the RC4, RSA,-
41 * lhash, DES, etc., code; not just the SSL code. The SSL documentation-
42 * included with this distribution is covered by the same copyright terms-
43 * except that the holder is Tim Hudson (tjh@cryptsoft.com).-
44 *-
45 * Copyright remains Eric Young's, and as such any Copyright notices in-
46 * the code are not to be removed.-
47 * If this package is used in a product, Eric Young should be given attribution-
48 * as the author of the parts of the library used.-
49 * This can be in the form of a textual message at program startup or-
50 * in documentation (online or textual) provided with the package.-
51 *-
52 * Redistribution and use in source and binary forms, with or without-
53 * modification, are permitted provided that the following conditions-
54 * are met:-
55 * 1. Redistributions of source code must retain the copyright-
56 * notice, this list of conditions and the following disclaimer.-
57 * 2. Redistributions in binary form must reproduce the above copyright-
58 * notice, this list of conditions and the following disclaimer in the-
59 * documentation and/or other materials provided with the distribution.-
60 * 3. All advertising materials mentioning features or use of this software-
61 * must display the following acknowledgement:-
62 * "This product includes cryptographic software written by-
63 * Eric Young (eay@cryptsoft.com)"-
64 * The word 'cryptographic' can be left out if the rouines from the library-
65 * being used are not cryptographic related :-).-
66 * 4. If you include any Windows specific code (or a derivative thereof) from-
67 * the apps directory (application code) you must include an acknowledgement:-
68 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"-
69 *-
70 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND-
71 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-
72 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE-
73 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE-
74 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL-
75 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS-
76 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)-
77 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT-
78 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY-
79 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF-
80 * SUCH DAMAGE.-
81 *-
82 * The licence and distribution terms for any publically available version or-
83 * derivative of this code cannot be changed. i.e. this code cannot simply be-
84 * copied and put under another distribution licence-
85 * [including the GNU Public Licence.]-
86 */-
87/* ====================================================================-
88 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.-
89 *-
90 * Redistribution and use in source and binary forms, with or without-
91 * modification, are permitted provided that the following conditions-
92 * are met:-
93 *-
94 * 1. Redistributions of source code must retain the above copyright-
95 * notice, this list of conditions and the following disclaimer.-
96 *-
97 * 2. Redistributions in binary form must reproduce the above copyright-
98 * notice, this list of conditions and the following disclaimer in-
99 * the documentation and/or other materials provided with the-
100 * distribution.-
101 *-
102 * 3. All advertising materials mentioning features or use of this-
103 * software must display the following acknowledgment:-
104 * "This product includes software developed by the OpenSSL Project-
105 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"-
106 *-
107 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to-
108 * endorse or promote products derived from this software without-
109 * prior written permission. For written permission, please contact-
110 * openssl-core@openssl.org.-
111 *-
112 * 5. Products derived from this software may not be called "OpenSSL"-
113 * nor may "OpenSSL" appear in their names without prior written-
114 * permission of the OpenSSL Project.-
115 *-
116 * 6. Redistributions of any form whatsoever must retain the following-
117 * acknowledgment:-
118 * "This product includes software developed by the OpenSSL Project-
119 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"-
120 *-
121 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY-
122 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-
123 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR-
124 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR-
125 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-
126 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT-
127 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;-
128 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)-
129 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,-
130 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)-
131 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED-
132 * OF THE POSSIBILITY OF SUCH DAMAGE.-
133 * ====================================================================-
134 *-
135 * This product includes cryptographic software written by Eric Young-
136 * (eay@cryptsoft.com). This product includes software written by Tim-
137 * Hudson (tjh@cryptsoft.com).-
138 *-
139 */-
140-
141#include <openssl/err.h>-
142#include <openssl/lhash.h>-
143-
144/* What an "implementation of ex_data functionality" looks like */-
145struct st_CRYPTO_EX_DATA_IMPL {-
146 /*********************/-
147 /* GLOBAL OPERATIONS */-
148 /* Return a new class index */-
149 int (*cb_new_class)(void);-
150 /* Cleanup all state used by the implementation */-
151 void (*cb_cleanup)(void);-
152 /************************/-
153 /* PER-CLASS OPERATIONS */-
154 /* Get a new method index within a class */-
155 int (*cb_get_new_index)(int class_index, long argl, void *argp,-
156 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,-
157 CRYPTO_EX_free *free_func);-
158 /* Initialise a new CRYPTO_EX_DATA of a given class */-
159 int (*cb_new_ex_data)(int class_index, void *obj,-
160 CRYPTO_EX_DATA *ad);-
161 /* Duplicate a CRYPTO_EX_DATA of a given class onto a copy */-
162 int (*cb_dup_ex_data)(int class_index, CRYPTO_EX_DATA *to,-
163 CRYPTO_EX_DATA *from);-
164 /* Cleanup a CRYPTO_EX_DATA of a given class */-
165 void (*cb_free_ex_data)(int class_index, void *obj,-
166 CRYPTO_EX_DATA *ad);-
167};-
168-
169/* The implementation we use at run-time */-
170static const CRYPTO_EX_DATA_IMPL *impl = NULL;-
171-
172/* To call "impl" functions, use this macro rather than referring to 'impl' directly, eg.-
173 * EX_IMPL(get_new_index)(...);-
174*/-
175#define EX_IMPL(a) impl->cb_##a-
176-
177/* Predeclare the "default" ex_data implementation */-
178static int int_new_class(void);-
179static void int_cleanup(void);-
180static int int_get_new_index(int class_index, long argl, void *argp,-
181 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,-
182 CRYPTO_EX_free *free_func);-
183static int int_new_ex_data(int class_index, void *obj,-
184 CRYPTO_EX_DATA *ad);-
185static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,-
186 CRYPTO_EX_DATA *from);-
187static void int_free_ex_data(int class_index, void *obj,-
188 CRYPTO_EX_DATA *ad);-
189-
190static CRYPTO_EX_DATA_IMPL impl_default = {-
191 int_new_class,-
192 int_cleanup,-
193 int_get_new_index,-
194 int_new_ex_data,-
195 int_dup_ex_data,-
196 int_free_ex_data-
197};-
198-
199/* Internal function that checks whether "impl" is set and if not, sets it to-
200 * the default. */-
201static void-
202impl_check(void)-
203{-
204 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);-
205 if (!impl)
!implDescription
TRUEevaluated 553 times by 31 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pbkdf2
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ...
FALSEnever evaluated
0-553
206 impl = &impl_default;
executed 553 times by 31 tests: impl = &impl_default;
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pbkdf2
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ...
553
207 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);-
208}
executed 553 times by 31 tests: end of block
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pbkdf2
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ...
553
209/* A macro wrapper for impl_check that first uses a non-locked test before-
210 * invoking the function (which checks again inside a lock). */-
211#define IMPL_CHECK if(!impl) impl_check();-
212-
213/* API functions to get/set the "ex_data" implementation */-
214const CRYPTO_EX_DATA_IMPL *-
215CRYPTO_get_ex_data_implementation(void)-
216{-
217 IMPL_CHECK
never executed: impl_check();
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
218 return impl;
never executed: return impl;
0
219}-
220-
221int-
222CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i)-
223{-
224 int toret = 0;-
225 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);-
226 if (!impl) {
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
227 impl = i;-
228 toret = 1;-
229 }
never executed: end of block
0
230 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);-
231 return toret;
never executed: return toret;
0
232}-
233-
234/****************************************************************************/-
235/* Interal (default) implementation of "ex_data" support. API functions are-
236 * further down. */-
237-
238/* The type that represents what each "class" used to implement locally. A STACK-
239 * of CRYPTO_EX_DATA_FUNCS plus a index-counter. The 'class_index' is the global-
240 * value representing the class that is used to distinguish these items. */-
241typedef struct st_ex_class_item {-
242 int class_index;-
243 STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth;-
244 int meth_num;-
245} EX_CLASS_ITEM;-
246-
247/* When assigning new class indexes, this is our counter */-
248static int ex_class = CRYPTO_EX_INDEX_USER;-
249-
250/* The global hash table of EX_CLASS_ITEM items */-
251DECLARE_LHASH_OF(EX_CLASS_ITEM);-
252static LHASH_OF(EX_CLASS_ITEM) *ex_data = NULL;-
253-
254/* The callbacks required in the "ex_data" hash table */-
255static unsigned long-
256ex_class_item_hash(const EX_CLASS_ITEM *a)-
257{-
258 return a->class_index;
executed 10277 times by 29 tests: return a->class_index;
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
10277
259}-
260-
261static
executed 10277 times by 29 tests: return ex_class_item_hash(a);
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
IMPLEMENT_LHASH_HASH_FN(ex_class_item, EX_CLASS_ITEM)
executed 10277 times by 29 tests: return ex_class_item_hash(a);
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
10277
262-
263static int-
264ex_class_item_cmp(const EX_CLASS_ITEM *a, const EX_CLASS_ITEM *b)-
265{-
266 return a->class_index - b->class_index;
executed 8177 times by 28 tests: return a->class_index - b->class_index;
Executed by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
8177
267}-
268-
269static
executed 8177 times by 28 tests: return ex_class_item_cmp(a,b);
Executed by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
IMPLEMENT_LHASH_COMP_FN(ex_class_item, EX_CLASS_ITEM)
executed 8177 times by 28 tests: return ex_class_item_cmp(a,b);
Executed by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
8177
270-
271/* Internal functions used by the "impl_default" implementation to access the-
272 * state */-
273-
274static int-
275ex_data_check(void)-
276{-
277 int toret = 1;-
278 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);-
279 if (!ex_data &&
!ex_dataDescription
TRUEevaluated 553 times by 31 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pbkdf2
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ...
FALSEnever evaluated
0-553
280 (ex_data = lh_EX_CLASS_ITEM_new()) == NULL)
(ex_data = ((s...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 553 times by 31 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pbkdf2
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ...
0-553
281 toret = 0;
never executed: toret = 0;
0
282 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);-
283 return toret;
executed 553 times by 31 tests: return toret;
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pbkdf2
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ...
553
284}-
285/* This macros helps reduce the locking from repeated checks because the-
286 * ex_data_check() function checks ex_data again inside a lock. */-
287#define EX_DATA_CHECK(iffail) if(!ex_data && !ex_data_check()) {iffail}-
288-
289/* This "inner" callback is used by the callback function that follows it */-
290static void-
291def_cleanup_util_cb(CRYPTO_EX_DATA_FUNCS *funcs)-
292{-
293 free(funcs);-
294}
executed 52 times by 2 tests: end of block
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
52
295-
296/* This callback is used in lh_doall to destroy all EX_CLASS_ITEM values from-
297 * "ex_data" prior to the ex_data hash table being itself destroyed. Doesn't do-
298 * any locking. */-
299static void-
300def_cleanup_cb(void *a_void)-
301{-
302 EX_CLASS_ITEM *item = (EX_CLASS_ITEM *)a_void;-
303 sk_CRYPTO_EX_DATA_FUNCS_pop_free(item->meth, def_cleanup_util_cb);-
304 free(item);-
305}
executed 714 times by 7 tests: end of block
Executed by:
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • libcrypto.so.44.0.1
  • ssltest
714
306-
307/* Return the EX_CLASS_ITEM from the "ex_data" hash table that corresponds to a-
308 * given class. Handles locking. */-
309static EX_CLASS_ITEM *-
310def_get_class(int class_index)-
311{-
312 EX_CLASS_ITEM d, *p, *gen;-
313 EX_DATA_CHECK(return NULL;)
never executed: return ((void *)0) ;
!ex_dataDescription
TRUEevaluated 551 times by 29 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
FALSEevaluated 8676 times by 28 tests
Evaluated by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
!ex_data_check()Description
TRUEnever evaluated
FALSEevaluated 551 times by 29 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
0-8676
314 d.class_index = class_index;-
315 if (!OPENSSL_init_crypto(0, NULL))
!OPENSSL_init_... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 9227 times by 29 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
0-9227
316 return NULL;
never executed: return ((void *)0) ;
0
317 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);-
318 p = lh_EX_CLASS_ITEM_retrieve(ex_data, &d);-
319 if (!p) {
!pDescription
TRUEevaluated 1050 times by 29 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
FALSEevaluated 8177 times by 28 tests
Evaluated by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
1050-8177
320 gen = malloc(sizeof(EX_CLASS_ITEM));-
321 if (gen) {
genDescription
TRUEevaluated 1050 times by 29 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
FALSEnever evaluated
0-1050
322 gen->class_index = class_index;-
323 gen->meth_num = 0;-
324 gen->meth = sk_CRYPTO_EX_DATA_FUNCS_new_null();-
325 if (!gen->meth)
!gen->methDescription
TRUEnever evaluated
FALSEevaluated 1050 times by 29 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
0-1050
326 free(gen);
never executed: free(gen);
0
327 else {-
328 /* Because we're inside the ex_data lock, the-
329 * return value from the insert will be NULL */-
330 (void)lh_EX_CLASS_ITEM_insert(ex_data, gen);-
331 p = gen;-
332 }
executed 1050 times by 29 tests: end of block
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
1050
333 }-
334 }
executed 1050 times by 29 tests: end of block
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
1050
335 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);-
336 if (!p)
!pDescription
TRUEnever evaluated
FALSEevaluated 9227 times by 29 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
0-9227
337 CRYPTOerror(ERR_R_MALLOC_FAILURE);
never executed: ERR_put_error(15,(0xfff),((1|64)),__FILE__,337);
0
338 return p;
executed 9227 times by 29 tests: return p;
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
9227
339}-
340-
341/* Add a new method to the given EX_CLASS_ITEM and return the corresponding-
342 * index (or -1 for error). Handles locking. */-
343static int-
344def_add_index(EX_CLASS_ITEM *item, long argl, void *argp,-
345 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)-
346{-
347 int toret = -1;-
348 CRYPTO_EX_DATA_FUNCS *a = malloc(sizeof(CRYPTO_EX_DATA_FUNCS));-
349-
350 if (!a) {
!aDescription
TRUEnever evaluated
FALSEevaluated 63 times by 13 tests
Evaluated by:
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • libcrypto.so.44.0.1
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
0-63
351 CRYPTOerror(ERR_R_MALLOC_FAILURE);-
352 return -1;
never executed: return -1;
0
353 }-
354 a->argl = argl;-
355 a->argp = argp;-
356 a->new_func = new_func;-
357 a->dup_func = dup_func;-
358 a->free_func = free_func;-
359 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);-
360 while (sk_CRYPTO_EX_DATA_FUNCS_num(item->meth) <= item->meth_num) {
sk_num(((_STAC...item->meth_numDescription
TRUEevaluated 63 times by 13 tests
Evaluated by:
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • libcrypto.so.44.0.1
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
FALSEevaluated 63 times by 13 tests
Evaluated by:
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • libcrypto.so.44.0.1
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
63
361 if (!sk_CRYPTO_EX_DATA_FUNCS_push(item->meth, NULL)) {
!sk_push(((_ST...TA_FUNCS*)0)))Description
TRUEnever evaluated
FALSEevaluated 63 times by 13 tests
Evaluated by:
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • libcrypto.so.44.0.1
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
0-63
362 CRYPTOerror(ERR_R_MALLOC_FAILURE);-
363 free(a);-
364 goto err;
never executed: goto err;
0
365 }-
366 }
executed 63 times by 13 tests: end of block
Executed by:
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • libcrypto.so.44.0.1
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
63
367 toret = item->meth_num++;-
368 (void)sk_CRYPTO_EX_DATA_FUNCS_set(item->meth, toret, a);-
369err:
code before this statement executed 63 times by 13 tests: err:
Executed by:
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • libcrypto.so.44.0.1
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
63
370 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);-
371 return toret;
executed 63 times by 13 tests: return toret;
Executed by:
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • libcrypto.so.44.0.1
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
63
372}-
373-
374/**************************************************************/-
375/* The functions in the default CRYPTO_EX_DATA_IMPL structure */-
376-
377static int-
378int_new_class(void)-
379{-
380 int toret;-
381-
382 CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);-
383 toret = ex_class++;-
384 CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);-
385 return toret;
never executed: return toret;
0
386}-
387-
388static void-
389int_cleanup(void)-
390{-
391 EX_DATA_CHECK(return;)
never executed: return;
!ex_dataDescription
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • evptest
  • pbkdf2
FALSEevaluated 266 times by 7 tests
Evaluated by:
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • libcrypto.so.44.0.1
  • ssltest
!ex_data_check()Description
TRUEnever evaluated
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • evptest
  • pbkdf2
0-266
392 lh_EX_CLASS_ITEM_doall(ex_data, def_cleanup_cb);-
393 lh_EX_CLASS_ITEM_free(ex_data);-
394 ex_data = NULL;-
395 impl = NULL;-
396}
executed 268 times by 9 tests: end of block
Executed by:
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • libcrypto.so.44.0.1
  • pbkdf2
  • ssltest
268
397-
398static int-
399int_get_new_index(int class_index, long argl, void *argp,-
400 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,-
401 CRYPTO_EX_free *free_func)-
402{-
403 EX_CLASS_ITEM *item = def_get_class(class_index);-
404-
405 if (!item)
!itemDescription
TRUEnever evaluated
FALSEevaluated 63 times by 13 tests
Evaluated by:
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • libcrypto.so.44.0.1
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
0-63
406 return -1;
never executed: return -1;
0
407 return def_add_index(item, argl, argp, new_func, dup_func, free_func);
executed 63 times by 13 tests: return def_add_index(item, argl, argp, new_func, dup_func, free_func);
Executed by:
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • libcrypto.so.44.0.1
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
63
408}-
409-
410/* Thread-safe by copying a class's array of "CRYPTO_EX_DATA_FUNCS" entries in-
411 * the lock, then using them outside the lock. NB: Thread-safety only applies to-
412 * the global "ex_data" state (ie. class definitions), not thread-safe on 'ad'-
413 * itself. */-
414static int-
415int_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)-
416{-
417 int mx, i;-
418 void *ptr;-
419 CRYPTO_EX_DATA_FUNCS **storage = NULL;-
420 EX_CLASS_ITEM *item = def_get_class(class_index);-
421-
422 if (!item)
!itemDescription
TRUEnever evaluated
FALSEevaluated 4600 times by 29 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
0-4600
423 /* error is already set */-
424 return 0;
never executed: return 0;
0
425 ad->sk = NULL;-
426 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);-
427 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);-
428 if (mx > 0) {
mx > 0Description
TRUEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
FALSEevaluated 4478 times by 29 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
122-4478
429 storage = reallocarray(NULL, mx, sizeof(CRYPTO_EX_DATA_FUNCS*));-
430 if (!storage)
!storageDescription
TRUEnever evaluated
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
0-122
431 goto skip;
never executed: goto skip;
0
432 for (i = 0; i < mx; i++)
i < mxDescription
TRUEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
122
433 storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(
executed 122 times by 3 tests: storage[i] = ((CRYPTO_EX_DATA_FUNCS *)sk_value(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)), (i))) ;
Executed by:
  • servertest
  • ssltest
  • tlstest
122
434 item->meth, i);
executed 122 times by 3 tests: storage[i] = ((CRYPTO_EX_DATA_FUNCS *)sk_value(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)), (i))) ;
Executed by:
  • servertest
  • ssltest
  • tlstest
122
435 }
executed 122 times by 3 tests: end of block
Executed by:
  • servertest
  • ssltest
  • tlstest
122
436skip:
code before this statement executed 4600 times by 29 tests: skip:
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
4600
437 CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);-
438 if ((mx > 0) && !storage) {
(mx > 0)Description
TRUEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
FALSEevaluated 4478 times by 29 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
!storageDescription
TRUEnever evaluated
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
0-4478
439 CRYPTOerror(ERR_R_MALLOC_FAILURE);-
440 return 0;
never executed: return 0;
0
441 }-
442 for (i = 0; i < mx; i++) {
i < mxDescription
TRUEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
FALSEevaluated 4600 times by 29 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
122-4600
443 if (storage[i] && storage[i]->new_func) {
storage[i]Description
TRUEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
FALSEnever evaluated
storage[i]->new_funcDescription
TRUEnever evaluated
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
0-122
444 ptr = CRYPTO_get_ex_data(ad, i);-
445 storage[i]->new_func(obj, ptr, ad, i,-
446 storage[i]->argl, storage[i]->argp);-
447 }
never executed: end of block
0
448 }
executed 122 times by 3 tests: end of block
Executed by:
  • servertest
  • ssltest
  • tlstest
122
449 free(storage);-
450 return 1;
executed 4600 times by 29 tests: return 1;
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
4600
451}-
452-
453/* Same thread-safety notes as for "int_new_ex_data" */-
454static int-
455int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from)-
456{-
457 int mx, j, i;-
458 char *ptr;-
459 CRYPTO_EX_DATA_FUNCS **storage = NULL;-
460 EX_CLASS_ITEM *item;-
461-
462 if (!from->sk)
!from->skDescription
TRUEnever evaluated
FALSEnever evaluated
0
463 /* 'to' should be "blank" which *is* just like 'from' */-
464 return 1;
never executed: return 1;
0
465 if ((item = def_get_class(class_index)) == NULL)
(item = def_ge...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
466 return 0;
never executed: return 0;
0
467 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);-
468 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);-
469 j = sk_void_num(from->sk);-
470 if (j < mx)
j < mxDescription
TRUEnever evaluated
FALSEnever evaluated
0
471 mx = j;
never executed: mx = j;
0
472 if (mx > 0) {
mx > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
473 storage = reallocarray(NULL, mx, sizeof(CRYPTO_EX_DATA_FUNCS*));-
474 if (!storage)
!storageDescription
TRUEnever evaluated
FALSEnever evaluated
0
475 goto skip;
never executed: goto skip;
0
476 for (i = 0; i < mx; i++)
i < mxDescription
TRUEnever evaluated
FALSEnever evaluated
0
477 storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(
never executed: storage[i] = ((CRYPTO_EX_DATA_FUNCS *)sk_value(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)), (i))) ;
0
478 item->meth, i);
never executed: storage[i] = ((CRYPTO_EX_DATA_FUNCS *)sk_value(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)), (i))) ;
0
479 }
never executed: end of block
0
480skip:
code before this statement never executed: skip:
0
481 CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);-
482 if ((mx > 0) && !storage) {
(mx > 0)Description
TRUEnever evaluated
FALSEnever evaluated
!storageDescription
TRUEnever evaluated
FALSEnever evaluated
0
483 CRYPTOerror(ERR_R_MALLOC_FAILURE);-
484 return 0;
never executed: return 0;
0
485 }-
486 for (i = 0; i < mx; i++) {
i < mxDescription
TRUEnever evaluated
FALSEnever evaluated
0
487 ptr = CRYPTO_get_ex_data(from, i);-
488 if (storage[i] && storage[i]->dup_func)
storage[i]Description
TRUEnever evaluated
FALSEnever evaluated
storage[i]->dup_funcDescription
TRUEnever evaluated
FALSEnever evaluated
0
489 storage[i]->dup_func(to, from, &ptr, i,
never executed: storage[i]->dup_func(to, from, &ptr, i, storage[i]->argl, storage[i]->argp);
0
490 storage[i]->argl, storage[i]->argp);
never executed: storage[i]->dup_func(to, from, &ptr, i, storage[i]->argl, storage[i]->argp);
0
491 CRYPTO_set_ex_data(to, i, ptr);-
492 }
never executed: end of block
0
493 free(storage);-
494 return 1;
never executed: return 1;
0
495}-
496-
497/* Same thread-safety notes as for "int_new_ex_data" */-
498static void-
499int_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)-
500{-
501 int mx, i;-
502 EX_CLASS_ITEM *item;-
503 void *ptr;-
504 CRYPTO_EX_DATA_FUNCS **storage = NULL;-
505-
506 if ((item = def_get_class(class_index)) == NULL)
(item = def_ge...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4564 times by 28 tests
Evaluated by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
0-4564
507 return;
never executed: return;
0
508 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);-
509 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);-
510 if (mx > 0) {
mx > 0Description
TRUEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
FALSEevaluated 4442 times by 28 tests
Evaluated by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
122-4442
511 storage = reallocarray(NULL, mx, sizeof(CRYPTO_EX_DATA_FUNCS*));-
512 if (!storage)
!storageDescription
TRUEnever evaluated
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
0-122
513 goto skip;
never executed: goto skip;
0
514 for (i = 0; i < mx; i++)
i < mxDescription
TRUEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
122
515 storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(
executed 122 times by 3 tests: storage[i] = ((CRYPTO_EX_DATA_FUNCS *)sk_value(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)), (i))) ;
Executed by:
  • servertest
  • ssltest
  • tlstest
122
516 item->meth, i);
executed 122 times by 3 tests: storage[i] = ((CRYPTO_EX_DATA_FUNCS *)sk_value(((_STACK*) (1 ? (item->meth) : (struct stack_st_CRYPTO_EX_DATA_FUNCS*)0)), (i))) ;
Executed by:
  • servertest
  • ssltest
  • tlstest
122
517 }
executed 122 times by 3 tests: end of block
Executed by:
  • servertest
  • ssltest
  • tlstest
122
518skip:
code before this statement executed 4564 times by 28 tests: skip:
Executed by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
4564
519 CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);-
520 if ((mx > 0) && !storage) {
(mx > 0)Description
TRUEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
FALSEevaluated 4442 times by 28 tests
Evaluated by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
!storageDescription
TRUEnever evaluated
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
0-4442
521 CRYPTOerror(ERR_R_MALLOC_FAILURE);-
522 return;
never executed: return;
0
523 }-
524 for (i = 0; i < mx; i++) {
i < mxDescription
TRUEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
FALSEevaluated 4564 times by 28 tests
Evaluated by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
122-4564
525 if (storage[i] && storage[i]->free_func) {
storage[i]Description
TRUEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
FALSEnever evaluated
storage[i]->free_funcDescription
TRUEnever evaluated
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
0-122
526 ptr = CRYPTO_get_ex_data(ad, i);-
527 storage[i]->free_func(obj, ptr, ad, i,-
528 storage[i]->argl, storage[i]->argp);-
529 }
never executed: end of block
0
530 }
executed 122 times by 3 tests: end of block
Executed by:
  • servertest
  • ssltest
  • tlstest
122
531 free(storage);-
532 if (ad->sk) {
ad->skDescription
TRUEevaluated 72 times by 2 tests
Evaluated by:
  • ssltest
  • tlstest
FALSEevaluated 4492 times by 28 tests
Evaluated by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
72-4492
533 sk_void_free(ad->sk);-
534 ad->sk = NULL;-
535 }
executed 72 times by 2 tests: end of block
Executed by:
  • ssltest
  • tlstest
72
536}
executed 4564 times by 28 tests: end of block
Executed by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
4564
537-
538/********************************************************************/-
539/* API functions that defer all "state" operations to the "ex_data"-
540 * implementation we have set. */-
541-
542/* Obtain an index for a new class (not the same as getting a new index within-
543 * an existing class - this is actually getting a new *class*) */-
544int-
545CRYPTO_ex_data_new_class(void)-
546{-
547 IMPL_CHECK
never executed: impl_check();
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
548 return EX_IMPL(new_class)();
never executed: return impl->cb_new_class();
0
549}-
550-
551/* Release all "ex_data" state to prevent memory leaks. This can't be made-
552 * thread-safe without overhauling a lot of stuff, and shouldn't really be-
553 * called under potential race-conditions anyway (it's for program shutdown-
554 * after all). */-
555void-
556CRYPTO_cleanup_all_ex_data(void)-
557{-
558 IMPL_CHECK
executed 2 times by 2 tests: impl_check();
Executed by:
  • evptest
  • pbkdf2
!implDescription
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • evptest
  • pbkdf2
FALSEevaluated 266 times by 7 tests
Evaluated by:
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • libcrypto.so.44.0.1
  • ssltest
2-266
559 EX_IMPL(cleanup)();-
560}
executed 268 times by 9 tests: end of block
Executed by:
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • evptest
  • libcrypto.so.44.0.1
  • pbkdf2
  • ssltest
268
561-
562/* Inside an existing class, get/register a new index. */-
563int-
564CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,-
565 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)-
566{-
567 int ret = -1;-
568-
569 IMPL_CHECK
executed 9 times by 9 tests: impl_check();
Executed by:
  • cipher_list
  • cipherstest
  • configtest
  • ssl_versions
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
!implDescription
TRUEevaluated 9 times by 9 tests
Evaluated by:
  • cipher_list
  • cipherstest
  • configtest
  • ssl_versions
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
FALSEevaluated 54 times by 4 tests
Evaluated by:
  • clienttest
  • libcrypto.so.44.0.1
  • servertest
  • ssltest
9-54
570 ret = EX_IMPL(get_new_index)(class_index,-
571 argl, argp, new_func, dup_func, free_func);-
572 return ret;
executed 63 times by 13 tests: return ret;
Executed by:
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • libcrypto.so.44.0.1
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
63
573}-
574-
575/* Initialise a new CRYPTO_EX_DATA for use in a particular class - including-
576 * calling new() callbacks for each index in the class used by this variable */-
577int-
578CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)-
579{-
580 IMPL_CHECK
executed 279 times by 20 tests: impl_check();
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • clienttest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssltest
!implDescription
TRUEevaluated 279 times by 20 tests
Evaluated by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • clienttest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssltest
FALSEevaluated 4321 times by 25 tests
Evaluated by:
  • asn1test
  • base64test
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
279-4321
581 return EX_IMPL(new_ex_data)(class_index, obj, ad);
executed 4600 times by 29 tests: return impl->cb_new_ex_data(class_index, obj, ad);
Executed by:
  • asn1test
  • base64test
  • bnaddsub
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • ...
4600
582}-
583-
584/* Duplicate a CRYPTO_EX_DATA variable - including calling dup() callbacks for-
585 * each index in the class used by this variable */-
586int-
587CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from)-
588{-
589 IMPL_CHECK
never executed: impl_check();
!implDescription
TRUEnever evaluated
FALSEnever evaluated
0
590 return EX_IMPL(dup_ex_data)(class_index, to, from);
never executed: return impl->cb_dup_ex_data(class_index, to, from);
0
591}-
592-
593/* Cleanup a CRYPTO_EX_DATA variable - including calling free() callbacks for-
594 * each index in the class used by this variable */-
595void-
596CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)-
597{-
598 IMPL_CHECK
executed 263 times by 4 tests: impl_check();
Executed by:
  • dsatest
  • ecdsatest
  • libcrypto.so.44.0.1
  • ssltest
!implDescription
TRUEevaluated 263 times by 4 tests
Evaluated by:
  • dsatest
  • ecdsatest
  • libcrypto.so.44.0.1
  • ssltest
FALSEevaluated 4301 times by 28 tests
Evaluated by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
263-4301
599 EX_IMPL(free_ex_data)(class_index, obj, ad);-
600}
executed 4564 times by 28 tests: end of block
Executed by:
  • asn1test
  • base64test
  • bntest
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • dhtest
  • dsatest
  • ecdhtest
  • ecdsatest
  • ectest
  • enginetest
  • exptest
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • mont
  • pkcs7test
  • rsa_test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • ...
4564
601-
602/* For a given CRYPTO_EX_DATA variable, set the value corresponding to a-
603 * particular index in the class used by this variable */-
604int-
605CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)-
606{-
607 int i;-
608-
609 if (ad->sk == NULL) {
ad->sk == ((void *)0)Description
TRUEevaluated 72 times by 2 tests
Evaluated by:
  • ssltest
  • tlstest
FALSEnever evaluated
0-72
610 if ((ad->sk = sk_void_new_null()) == NULL) {
(ad->sk = ((st...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • ssltest
  • tlstest
0-72
611 CRYPTOerror(ERR_R_MALLOC_FAILURE);-
612 return (0);
never executed: return (0);
0
613 }-
614 }
executed 72 times by 2 tests: end of block
Executed by:
  • ssltest
  • tlstest
72
615 i = sk_void_num(ad->sk);-
616-
617 while (i <= idx) {
i <= idxDescription
TRUEevaluated 72 times by 2 tests
Evaluated by:
  • ssltest
  • tlstest
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • ssltest
  • tlstest
72
618 if (!sk_void_push(ad->sk, NULL)) {
!sk_push(((_ST... : (void*)0)))Description
TRUEnever evaluated
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • ssltest
  • tlstest
0-72
619 CRYPTOerror(ERR_R_MALLOC_FAILURE);-
620 return (0);
never executed: return (0);
0
621 }-
622 i++;-
623 }
executed 72 times by 2 tests: end of block
Executed by:
  • ssltest
  • tlstest
72
624 sk_void_set(ad->sk, idx, val);-
625 return (1);
executed 72 times by 2 tests: return (1);
Executed by:
  • ssltest
  • tlstest
72
626}-
627-
628/* For a given CRYPTO_EX_DATA_ variable, get the value corresponding to a-
629 * particular index in the class used by this variable */-
630void *-
631CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)-
632{-
633 if (ad->sk == NULL)
ad->sk == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tlstest
0-12
634 return (0);
never executed: return (0);
0
635 else if (idx >= sk_void_num(ad->sk))
idx >= sk_num(..._st_void*)0)))Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tlstest
0-12
636 return (0);
never executed: return (0);
0
637 else-
638 return (sk_void_value(ad->sk, idx));
executed 12 times by 1 test: return (((void *)sk_value(((_STACK*) (1 ? (ad->sk) : (struct stack_st_void*)0)), (idx))));
Executed by:
  • tlstest
12
639}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2