OpenCoverage

mem_sec.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/mem_sec.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10static size_t secure_mem_used;-
11-
12static int secure_mem_initialized;-
13-
14static CRYPTO_RWLOCK *sec_malloc_lock = -
15 ((void *)0)-
16 ;-
17-
18-
19-
20-
21static int sh_init(size_t size, int minsize);-
22static void *sh_malloc(size_t size);-
23static void sh_free(void *ptr);-
24static void sh_done(void);-
25static size_t sh_actual_size(char *ptr);-
26static int sh_allocated(const char *ptr);-
27-
28-
29int CRYPTO_secure_malloc_init(size_t size, int minsize)-
30{-
31-
32 int ret = 0;-
33-
34 if (!secure_mem_initialized
!secure_mem_initializedDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-4
35 sec_malloc_lock = CRYPTO_THREAD_lock_new();-
36 if (sec_malloc_lock ==
sec_malloc_lock == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
37 ((void *)0)
sec_malloc_lock == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
38 )-
39 return
never executed: return 0;
0;
never executed: return 0;
0
40 if ((
(ret = sh_init...minsize)) != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
ret = sh_init(size, minsize)) != 0
(ret = sh_init...minsize)) != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
1-3
41 secure_mem_initialized = 1;-
42 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else {
3
43 CRYPTO_THREAD_lock_free(sec_malloc_lock);-
44 sec_malloc_lock = -
45 ((void *)0)-
46 ;-
47 }
executed 1 time by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1
48 }-
49-
50 return
executed 4 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 4 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
4
51-
52-
53-
54}-
55-
56int CRYPTO_secure_malloc_done(void)-
57{-
58-
59 if (secure_mem_used == 0
secure_mem_used == 0Description
TRUEevaluated 2079 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
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
1-2079
60 sh_done();-
61 secure_mem_initialized = 0;-
62 CRYPTO_THREAD_lock_free(sec_malloc_lock);-
63 sec_malloc_lock = -
64 ((void *)0)-
65 ;-
66 return
executed 2079 times by 12 tests: return 1;
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
1;
executed 2079 times by 12 tests: return 1;
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
2079
67 }-
68-
69 return
executed 1 time by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
0;
executed 1 time by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
1
70}-
71-
72int CRYPTO_secure_malloc_initialized(void)-
73{-
74-
75 return
executed 3 times by 1 test: return secure_mem_initialized;
Executed by:
  • libcrypto.so.1.1
secure_mem_initialized;
executed 3 times by 1 test: return secure_mem_initialized;
Executed by:
  • libcrypto.so.1.1
3
76-
77-
78-
79}-
80-
81void *CRYPTO_secure_malloc(size_t num, const char *file, int line)-
82{-
83-
84 void *ret;-
85 size_t actual_size;-
86-
87 if (!secure_mem_initialized
!secure_mem_initializedDescription
TRUEevaluated 85716 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
4-85716
88 return
executed 85716 times by 1 test: return CRYPTO_malloc(num, file, line);
Executed by:
  • libcrypto.so.1.1
CRYPTO_malloc(num, file, line);
executed 85716 times by 1 test: return CRYPTO_malloc(num, file, line);
Executed by:
  • libcrypto.so.1.1
85716
89 }-
90 CRYPTO_THREAD_write_lock(sec_malloc_lock);-
91 ret = sh_malloc(num);-
92 actual_size = ret
retDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
? sh_actual_size(ret) : 0;
1-3
93 secure_mem_used += actual_size;-
94 CRYPTO_THREAD_unlock(sec_malloc_lock);-
95 return
executed 4 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 4 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
4
96-
97-
98-
99}-
100-
101void *CRYPTO_secure_zalloc(size_t num, const char *file, int line)-
102{-
103-
104 if (secure_mem_initialized
secure_mem_initializedDescription
TRUEnever evaluated
FALSEevaluated 1146154 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
)
0-1146154
105-
106 return
never executed: return CRYPTO_secure_malloc(num, file, line);
CRYPTO_secure_malloc(num, file, line);
never executed: return CRYPTO_secure_malloc(num, file, line);
0
107-
108 return
executed 1146206 times by 2 tests: return CRYPTO_zalloc(num, file, line);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
CRYPTO_zalloc(num, file, line);
executed 1146206 times by 2 tests: return CRYPTO_zalloc(num, file, line);
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1146206
109}-
110-
111void CRYPTO_secure_free(void *ptr, const char *file, int line)-
112{-
113-
114 size_t actual_size;-
115-
116 if (ptr ==
ptr == ((void *)0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 89963 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
6-89963
117 ((void *)0)
ptr == ((void *)0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 89963 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
6-89963
118 )-
119 return;
executed 6 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
6
120 if (!CRYPTO_secure_allocated(ptr)
!CRYPTO_secure_allocated(ptr)Description
TRUEevaluated 89961 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
2-89961
121 CRYPTO_free(ptr, file, line);-
122 return;
executed 89961 times by 2 tests: return;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
89961
123 }-
124 CRYPTO_THREAD_write_lock(sec_malloc_lock);-
125 actual_size = sh_actual_size(ptr);-
126 OPENSSL_cleanse(ptr, actual_size);-
127 secure_mem_used -= actual_size;-
128 sh_free(ptr);-
129 CRYPTO_THREAD_unlock(sec_malloc_lock);-
130-
131-
132-
133}
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
134-
135void CRYPTO_secure_clear_free(void *ptr, size_t num,-
136 const char *file, int line)-
137{-
138-
139 size_t actual_size;-
140-
141 if (ptr ==
ptr == ((void *)0)Description
TRUEevaluated 1083348 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 1110433 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
1083348-1110433
142 ((void *)0)
ptr == ((void *)0)Description
TRUEevaluated 1083348 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 1110433 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
1083348-1110433
143 )-
144 return;
executed 1082014 times by 2 tests: return;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1082014
145 if (!CRYPTO_secure_allocated(ptr)
!CRYPTO_secure_allocated(ptr)Description
TRUEevaluated 1123891 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
1-1123891
146 OPENSSL_cleanse(ptr, num);-
147 CRYPTO_free(ptr, file, line);-
148 return;
executed 1140790 times by 2 tests: return;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1140790
149 }-
150 CRYPTO_THREAD_write_lock(sec_malloc_lock);-
151 actual_size = sh_actual_size(ptr);-
152 OPENSSL_cleanse(ptr, actual_size);-
153 secure_mem_used -= actual_size;-
154 sh_free(ptr);-
155 CRYPTO_THREAD_unlock(sec_malloc_lock);-
156-
157-
158-
159-
160-
161-
162}
executed 1 time by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1
163-
164int CRYPTO_secure_allocated(const void *ptr)-
165{-
166-
167 int ret;-
168-
169 if (!secure_mem_initialized
!secure_mem_initializedDescription
TRUEevaluated 1194110 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
8-1194110
170 return
executed 1188449 times by 2 tests: return 0;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
0;
executed 1188449 times by 2 tests: return 0;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
1188449
171 CRYPTO_THREAD_write_lock(sec_malloc_lock);-
172 ret = sh_allocated(ptr);-
173 CRYPTO_THREAD_unlock(sec_malloc_lock);-
174 return
executed 8 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 8 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
8
175-
176-
177-
178}-
179-
180size_t CRYPTO_secure_used(void)-
181{-
182-
183 return
executed 4 times by 1 test: return secure_mem_used;
Executed by:
  • libcrypto.so.1.1
secure_mem_used;
executed 4 times by 1 test: return secure_mem_used;
Executed by:
  • libcrypto.so.1.1
4
184-
185-
186-
187}-
188-
189size_t CRYPTO_secure_actual_size(void *ptr)-
190{-
191-
192 size_t actual_size;-
193-
194 CRYPTO_THREAD_write_lock(sec_malloc_lock);-
195 actual_size = sh_actual_size(ptr);-
196 CRYPTO_THREAD_unlock(sec_malloc_lock);-
197 return
never executed: return actual_size;
actual_size;
never executed: return actual_size;
0
198-
199-
200-
201}-
202typedef struct sh_list_st-
203{-
204 struct sh_list_st *next;-
205 struct sh_list_st **p_next;-
206} SH_LIST;-
207-
208typedef struct sh_st-
209{-
210 char* map_result;-
211 size_t map_size;-
212 char *arena;-
213 size_t arena_size;-
214 char **freelist;-
215 ssize_t freelist_size;-
216 size_t minsize;-
217 unsigned char *bittable;-
218 unsigned char *bitmalloc;-
219 size_t bittable_size;-
220} SH;-
221-
222static SH sh;-
223-
224static size_t sh_getlist(char *ptr)-
225{-
226 ssize_t list = sh.freelist_size - 1;-
227 size_t bit = (sh.arena_size + ptr - sh.arena) / sh.minsize;-
228-
229 for (; bit
bitDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
; bit >>= 1, list--) {
0-12
230 if ((
(sh.bittable[(... ((bit) & 7)))Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
sh.bittable[(bit) >> 3] & (((size_t)1) << ((bit) & 7)))
(sh.bittable[(... ((bit) & 7)))Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
3-9
231 break;
executed 9 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
9
232 (void)(((bit & 1) == 0) ? 0 : (OPENSSL_die("assertion failed: " "(bit & 1) == 0", __FILE__, 302), 1));-
233 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3
234-
235 return
executed 9 times by 1 test: return list;
Executed by:
  • libcrypto.so.1.1
list;
executed 9 times by 1 test: return list;
Executed by:
  • libcrypto.so.1.1
9
236}-
237-
238-
239static int sh_testbit(char *ptr, int list, unsigned char *table)-
240{-
241 size_t bit;-
242-
243 (void)((list >= 0 && list < sh.freelist_size) ? 0 : (OPENSSL_die("assertion failed: " "list >= 0 && list < sh.freelist_size", __FILE__, 313), 1));-
244 (void)((((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0) ? 0 : (OPENSSL_die("assertion failed: " "((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0", __FILE__, 314), 1));-
245 bit = (((size_t)1) << list) + ((ptr - sh.arena) / (sh.arena_size >> list));-
246 (void)((bit > 0 && bit < sh.bittable_size) ? 0 : (OPENSSL_die("assertion failed: " "bit > 0 && bit < sh.bittable_size", __FILE__, 316), 1));-
247 return
executed 90 times by 1 test: return (table[(bit) >> 3] & (((size_t)1) << ((bit) & 7)));
Executed by:
  • libcrypto.so.1.1
(table[(bit) >> 3] & (((size_t)1) << ((bit) & 7)));
executed 90 times by 1 test: return (table[(bit) >> 3] & (((size_t)1) << ((bit) & 7)));
Executed by:
  • libcrypto.so.1.1
90
248}-
249-
250static void sh_clearbit(char *ptr, int list, unsigned char *table)-
251{-
252 size_t bit;-
253-
254 (void)((list >= 0 && list < sh.freelist_size) ? 0 : (OPENSSL_die("assertion failed: " "list >= 0 && list < sh.freelist_size", __FILE__, 324), 1));-
255 (void)((((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0) ? 0 : (OPENSSL_die("assertion failed: " "((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0", __FILE__, 325), 1));-
256 bit = (((size_t)1) << list) + ((ptr - sh.arena) / (sh.arena_size >> list));-
257 (void)((bit > 0 && bit < sh.bittable_size) ? 0 : (OPENSSL_die("assertion failed: " "bit > 0 && bit < sh.bittable_size", __FILE__, 327), 1));-
258 (void)(((table[(bit) >> 3] & (((size_t)1) << ((bit) & 7)))) ? 0 : (OPENSSL_die("assertion failed: " "TESTBIT(table, bit)", __FILE__, 328), 1));-
259 (table[(bit) >> 3] &= (0xFF & ~(((size_t)1) << ((bit) & 7))));-
260}
executed 42 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
42
261-
262static void sh_setbit(char *ptr, int list, unsigned char *table)-
263{-
264 size_t bit;-
265-
266 (void)((list >= 0 && list < sh.freelist_size) ? 0 : (OPENSSL_die("assertion failed: " "list >= 0 && list < sh.freelist_size", __FILE__, 336), 1));-
267 (void)((((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0) ? 0 : (OPENSSL_die("assertion failed: " "((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0", __FILE__, 337), 1));-
268 bit = (((size_t)1) << list) + ((ptr - sh.arena) / (sh.arena_size >> list));-
269 (void)((bit > 0 && bit < sh.bittable_size) ? 0 : (OPENSSL_die("assertion failed: " "bit > 0 && bit < sh.bittable_size", __FILE__, 339), 1));-
270 (void)((!(table[(bit) >> 3] & (((size_t)1) << ((bit) & 7)))) ? 0 : (OPENSSL_die("assertion failed: " "!TESTBIT(table, bit)", __FILE__, 340), 1));-
271 (table[(bit) >> 3] |= (((size_t)1) << ((bit) & 7)));-
272}
executed 45 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
45
273-
274static void sh_add_to_list(char **list, char *ptr)-
275{-
276 SH_LIST *temp;-
277-
278 (void)((((char*)(list) >= (char*)sh.freelist && (char*)(list) < (char*)&sh.freelist[sh.freelist_size])) ? 0 : (OPENSSL_die("assertion failed: " "WITHIN_FREELIST(list)", __FILE__, 348), 1));-
279 (void)((((char*)(ptr) >= sh.arena && (char*)(ptr) < &sh.arena[sh.arena_size])) ? 0 : (OPENSSL_die("assertion failed: " "WITHIN_ARENA(ptr)", __FILE__, 349), 1));-
280-
281 temp = (SH_LIST *)ptr;-
282 temp->next = *(SH_LIST **)list;-
283 (void)((temp->next == -
284 ((void *)0) -
285 || ((char*)(temp->next) >= sh.arena && (char*)(temp->next) < &sh.arena[sh.arena_size])) ? 0 : (OPENSSL_die("assertion failed: " "temp->next == NULL || WITHIN_ARENA(temp->next)", __FILE__, 353), 1));-
286 temp->p_next = (SH_LIST **)list;-
287-
288 if (temp->next !=
temp->next != ((void *)0)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 19 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
19-26
289 ((void *)0)
temp->next != ((void *)0)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 19 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
19-26
290 ) {-
291 (void)(((char **)temp->next->p_next == list) ? 0 : (OPENSSL_die("assertion failed: " "(char **)temp->next->p_next == list", __FILE__, 357), 1));-
292 temp->next->p_next = &(temp->next);-
293 }
executed 26 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
26
294-
295 *list = ptr;-
296}
executed 45 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
45
297-
298static void sh_remove_from_list(char *ptr)-
299{-
300 SH_LIST *temp, *temp2;-
301-
302 temp = (SH_LIST *)ptr;-
303 if (temp->next !=
temp->next != ((void *)0)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
16-26
304 ((void *)0)
temp->next != ((void *)0)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
16-26
305 )-
306 temp->next->p_next = temp->p_next;
executed 26 times by 1 test: temp->next->p_next = temp->p_next;
Executed by:
  • libcrypto.so.1.1
26
307 *temp->p_next = temp->next;-
308 if (temp->next ==
temp->next == ((void *)0)Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
16-26
309 ((void *)0)
temp->next == ((void *)0)Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
16-26
310 )-
311 return;
executed 16 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
16
312-
313 temp2 = temp->next;-
314 (void)((((char*)(temp2->p_next) >= (char*)sh.freelist && (char*)(temp2->p_next) < (char*)&sh.freelist[sh.freelist_size]) || ((char*)(temp2->p_next) >= sh.arena && (char*)(temp2->p_next) < &sh.arena[sh.arena_size])) ? 0 : (OPENSSL_die("assertion failed: " "WITHIN_FREELIST(temp2->p_next) || WITHIN_ARENA(temp2->p_next)", __FILE__, 376), 1));-
315}
executed 26 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
26
316-
317-
318static int sh_init(size_t size, int minsize)-
319{-
320 int ret;-
321 size_t i;-
322 size_t pgsize;-
323 size_t aligned;-
324-
325 memset(&sh, 0, sizeof(sh));-
326-
327-
328 (void)((size > 0) ? 0 : (OPENSSL_die("assertion failed: " "size > 0", __FILE__, 390), 1));-
329 (void)(((size & (size - 1)) == 0) ? 0 : (OPENSSL_die("assertion failed: " "(size & (size - 1)) == 0", __FILE__, 391), 1));-
330 (void)((minsize > 0) ? 0 : (OPENSSL_die("assertion failed: " "minsize > 0", __FILE__, 392), 1));-
331 (void)(((minsize & (minsize - 1)) == 0) ? 0 : (OPENSSL_die("assertion failed: " "(minsize & (minsize - 1)) == 0", __FILE__, 393), 1));-
332 if (size <= 0
size <= 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| (
(size & (size - 1)) != 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
size & (size - 1)) != 0
(size & (size - 1)) != 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-4
333 goto
never executed: goto err;
err;
never executed: goto err;
0
334 if (minsize <= 0
minsize <= 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| (
(minsize & (minsize - 1)) != 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
minsize & (minsize - 1)) != 0
(minsize & (minsize - 1)) != 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-4
335 goto
never executed: goto err;
err;
never executed: goto err;
0
336-
337 while (minsize < (int)sizeof(SH_LIST)
minsize < (int)sizeof(SH_LIST)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-4
338 minsize *= 2;
never executed: minsize *= 2;
0
339-
340 sh.arena_size = size;-
341 sh.minsize = minsize;-
342 sh.bittable_size = (sh.arena_size / sh.minsize) * 2;-
343-
344-
345 if (sh.bittable_size >> 3 == 0
sh.bittable_size >> 3 == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
1-3
346 goto
executed 1 time by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
err;
executed 1 time by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
1
347-
348 sh.freelist_size = -1;-
349 for (i = sh.bittable_size; i
iDescription
TRUEevaluated 31 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i >>= 1)
3-31
350 sh.freelist_size++;
executed 31 times by 1 test: sh.freelist_size++;
Executed by:
  • libcrypto.so.1.1
31
351-
352 sh.freelist = CRYPTO_zalloc(sh.freelist_size * sizeof(char *), __FILE__, 414);-
353 (void)((sh.freelist != -
354 ((void *)0)-
355 ) ? 0 : (OPENSSL_die("assertion failed: " "sh.freelist != NULL", __FILE__, 415), 1));-
356 if (sh.freelist ==
sh.freelist == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
357 ((void *)0)
sh.freelist == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
358 )-
359 goto
never executed: goto err;
err;
never executed: goto err;
0
360-
361 sh.bittable = CRYPTO_zalloc(sh.bittable_size >> 3, __FILE__, 419);-
362 (void)((sh.bittable != -
363 ((void *)0)-
364 ) ? 0 : (OPENSSL_die("assertion failed: " "sh.bittable != NULL", __FILE__, 420), 1));-
365 if (sh.bittable ==
sh.bittable == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
366 ((void *)0)
sh.bittable == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
367 )-
368 goto
never executed: goto err;
err;
never executed: goto err;
0
369-
370 sh.bitmalloc = CRYPTO_zalloc(sh.bittable_size >> 3, __FILE__, 424);-
371 (void)((sh.bitmalloc != -
372 ((void *)0)-
373 ) ? 0 : (OPENSSL_die("assertion failed: " "sh.bitmalloc != NULL", __FILE__, 425), 1));-
374 if (sh.bitmalloc ==
sh.bitmalloc == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
375 ((void *)0)
sh.bitmalloc == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
376 )-
377 goto
never executed: goto err;
err;
never executed: goto err;
0
378-
379-
380-
381 {-
382-
383 long tmppgsize = sysconf(-
384 _SC_PAGESIZE-
385 );-
386-
387-
388-
389 if (tmppgsize < 1
tmppgsize < 1Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-3
390 pgsize = 4096;
never executed: pgsize = 4096;
0
391 else-
392 pgsize = (size_t)tmppgsize;
executed 3 times by 1 test: pgsize = (size_t)tmppgsize;
Executed by:
  • libcrypto.so.1.1
3
393 }-
394-
395-
396-
397 sh.map_size = pgsize + sh.arena_size + pgsize;-
398 if (1) {-
399-
400 sh.map_result = mmap(-
401 ((void *)0)-
402 , sh.map_size,-
403 -
404 0x1-
405 |-
406 0x2-
407 , -
408 0x20-
409 |-
410 0x02-
411 , -1, 0);-
412 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
else {
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
413-
414 int fd;
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
415-
416 sh.map_result =
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
417 ((void *) -1)
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
418 ;
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
419 if ((fd = open("/dev/zero",
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
420 02
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
421 )) >= 0) {
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
422 sh.map_result = mmap(
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
423 ((void *)0)
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
424 , sh.map_size,
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
425
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
426 0x1
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
427 |
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
428 0x2
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
429 ,
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
430 0x02
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
431 , fd, 0);
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
432 close(fd);
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
433 }
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
434 }
dead code: { int fd; sh.map_result = ((void *) -1) ; if ((fd = open("/dev/zero", 02 )) >= 0) { sh.map_result = mmap( ((void *)0) , sh.map_size, 0x1 | 0x2 , 0x02 , fd, 0); close(fd); } }
-
435 if (sh.map_result ==
sh.map_result == ((void *) -1)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
436 ((void *) -1)
sh.map_result == ((void *) -1)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
437 )-
438 goto
never executed: goto err;
err;
never executed: goto err;
0
439 sh.arena = (char *)(sh.map_result + pgsize);-
440 sh_setbit(sh.arena, 0, sh.bittable);-
441 sh_add_to_list(&sh.freelist[0], sh.arena);-
442-
443-
444 ret = 1;-
445-
446-
447 if (mprotect(sh.map_result, pgsize,
mprotect(sh.ma...ize, 0x0 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
448 0x0
mprotect(sh.ma...ize, 0x0 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
449 ) < 0
mprotect(sh.ma...ize, 0x0 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-3
450 ret = 2;
never executed: ret = 2;
0
451-
452-
453 aligned = (pgsize + sh.arena_size + (pgsize - 1)) & ~(pgsize - 1);-
454 if (mprotect(sh.map_result + aligned, pgsize,
mprotect(sh.ma...ize, 0x0 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
455 0x0
mprotect(sh.ma...ize, 0x0 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
456 ) < 0
mprotect(sh.ma...ize, 0x0 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-3
457 ret = 2;
never executed: ret = 2;
0
458-
459-
460 if (syscall(
syscall( 325 ,...ze, 0x01 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
461 325
syscall( 325 ,...ze, 0x01 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
462 , sh.arena, sh.arena_size,
syscall( 325 ,...ze, 0x01 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
463 0x01
syscall( 325 ,...ze, 0x01 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
464 ) < 0
syscall( 325 ,...ze, 0x01 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-3
465 if (-
466 (*
(*__errno_location ()) == 38Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) == 38Description
TRUEnever evaluated
FALSEnever evaluated
0
467 ==
(*__errno_location ()) == 38Description
TRUEnever evaluated
FALSEnever evaluated
0
468 38
(*__errno_location ()) == 38Description
TRUEnever evaluated
FALSEnever evaluated
0
469 ) {-
470 if (mlock(sh.arena, sh.arena_size) < 0
mlock(sh.arena...rena_size) < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
471 ret = 2;
never executed: ret = 2;
0
472 }
never executed: end of block
else {
0
473 ret = 2;-
474 }
never executed: end of block
0
475 }-
476-
477-
478-
479-
480-
481 if (madvise(sh.arena, sh.arena_size,
madvise(sh.are...size, 16 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
482 16
madvise(sh.are...size, 16 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
483 ) < 0
madvise(sh.are...size, 16 ) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-3
484 ret = 2;
never executed: ret = 2;
0
485-
486-
487 return
executed 3 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 3 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
3
488-
489 err:-
490 sh_done();-
491 return
executed 1 time by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
0;
executed 1 time by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
1
492}-
493-
494static void sh_done(void)-
495{-
496 CRYPTO_free(sh.freelist, __FILE__, 506);-
497 CRYPTO_free(sh.bittable, __FILE__, 507);-
498 CRYPTO_free(sh.bitmalloc, __FILE__, 508);-
499 if (sh.map_result !=
sh.map_result != ((void *)0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2077 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
3-2077
500 ((void *)0)
sh.map_result != ((void *)0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2077 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
3-2077
501 && sh.map_size
sh.map_sizeDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-3
502 munmap(sh.map_result, sh.map_size);
executed 3 times by 1 test: munmap(sh.map_result, sh.map_size);
Executed by:
  • libcrypto.so.1.1
3
503 memset(&sh, 0, sizeof(sh));-
504}
executed 2080 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
2080
505-
506static int sh_allocated(const char *ptr)-
507{-
508 return
executed 8 times by 1 test: return ((char*)(ptr) >= sh.arena && (char*)(ptr) < &sh.arena[sh.arena_size]) ? 1 : 0;
Executed by:
  • libcrypto.so.1.1
((
(char*)(ptr) >= sh.arenaDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
char*)(ptr) >= sh.arena
(char*)(ptr) >= sh.arenaDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& (
(char*)(ptr) <...sh.arena_size]Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
char*)(ptr) < &sh.arena[sh.arena_size]
(char*)(ptr) <...sh.arena_size]Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) ? 1 : 0;
executed 8 times by 1 test: return ((char*)(ptr) >= sh.arena && (char*)(ptr) < &sh.arena[sh.arena_size]) ? 1 : 0;
Executed by:
  • libcrypto.so.1.1
0-8
509}-
510-
511static char *sh_find_my_buddy(char *ptr, int list)-
512{-
513 size_t bit;-
514 char *chunk = -
515 ((void *)0)-
516 ;-
517-
518 bit = (((size_t)1) << list) + (ptr - sh.arena) / (sh.arena_size >> list);-
519 bit ^= 1;-
520-
521 if ((
(sh.bittable[(... ((bit) & 7)))Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
sh.bittable[(bit) >> 3] & (((size_t)1) << ((bit) & 7)))
(sh.bittable[(... ((bit) & 7)))Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
&& !(sh.bitmalloc[(bit) >> 3] & (((size_t)1) << ((bit) & 7)))
!(sh.bitmalloc... ((bit) & 7)))Description
TRUEevaluated 39 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
1-40
522 chunk = sh.arena + ((bit & ((((size_t)1) << list) - 1)) * (sh.arena_size >> list));
executed 39 times by 1 test: chunk = sh.arena + ((bit & ((((size_t)1) << list) - 1)) * (sh.arena_size >> list));
Executed by:
  • libcrypto.so.1.1
39
523-
524 return
executed 42 times by 1 test: return chunk;
Executed by:
  • libcrypto.so.1.1
chunk;
executed 42 times by 1 test: return chunk;
Executed by:
  • libcrypto.so.1.1
42
525}-
526-
527static void *sh_malloc(size_t size)-
528{-
529 ssize_t list, slist;-
530 size_t i;-
531 char *chunk;-
532-
533 if (size > sh.arena_size
size > sh.arena_sizeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
1-3
534 return
executed 1 time by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
executed 1 time by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
1
535 ((void *)0)
executed 1 time by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
1
536 ;
executed 1 time by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
1
537-
538 list = sh.freelist_size - 1;-
539 for (i = sh.minsize; i < size
i < sizeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
; i <<= 1)
1-3
540 list--;
executed 1 time by 1 test: list--;
Executed by:
  • libcrypto.so.1.1
1
541 if (list < 0
list < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-3
542 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
543 ((void *)0)
never executed: return ((void *)0) ;
0
544 ;
never executed: return ((void *)0) ;
0
545-
546-
547 for (slist = list; slist >= 0
slist >= 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
; slist--)
0-16
548 if (sh.freelist[slist] !=
sh.freelist[sl...!= ((void *)0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3-13
549 ((void *)0)
sh.freelist[sl...!= ((void *)0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3-13
550 )-
551 break;
executed 3 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
3
552 if (slist < 0
slist < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-3
553 return
never executed: return ((void *)0) ;
never executed: return ((void *)0) ;
0
554 ((void *)0)
never executed: return ((void *)0) ;
0
555 ;
never executed: return ((void *)0) ;
0
556-
557-
558 while (slist != list
slist != listDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
3-13
559 char *temp = sh.freelist[slist];-
560-
561-
562 (void)((!sh_testbit(temp, slist, sh.bitmalloc)) ? 0 : (OPENSSL_die("assertion failed: " "!sh_testbit(temp, slist, sh.bitmalloc)", __FILE__, 560), 1));-
563 sh_clearbit(temp, slist, sh.bittable);-
564 sh_remove_from_list(temp);-
565 (void)((temp != sh.freelist[slist]) ? 0 : (OPENSSL_die("assertion failed: " "temp != sh.freelist[slist]", __FILE__, 563), 1));-
566-
567-
568 slist++;-
569-
570-
571 (void)((!sh_testbit(temp, slist, sh.bitmalloc)) ? 0 : (OPENSSL_die("assertion failed: " "!sh_testbit(temp, slist, sh.bitmalloc)", __FILE__, 569), 1));-
572 sh_setbit(temp, slist, sh.bittable);-
573 sh_add_to_list(&sh.freelist[slist], temp);-
574 (void)((sh.freelist[slist] == temp) ? 0 : (OPENSSL_die("assertion failed: " "sh.freelist[slist] == temp", __FILE__, 572), 1));-
575-
576-
577 temp += sh.arena_size >> slist;-
578 (void)((!sh_testbit(temp, slist, sh.bitmalloc)) ? 0 : (OPENSSL_die("assertion failed: " "!sh_testbit(temp, slist, sh.bitmalloc)", __FILE__, 576), 1));-
579 sh_setbit(temp, slist, sh.bittable);-
580 sh_add_to_list(&sh.freelist[slist], temp);-
581 (void)((sh.freelist[slist] == temp) ? 0 : (OPENSSL_die("assertion failed: " "sh.freelist[slist] == temp", __FILE__, 579), 1));-
582-
583 (void)((temp-(sh.arena_size >> slist) == sh_find_my_buddy(temp, slist)) ? 0 : (OPENSSL_die("assertion failed: " "temp-(sh.arena_size >> slist) == sh_find_my_buddy(temp, slist)", __FILE__, 581), 1));-
584 }
executed 13 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
13
585-
586-
587 chunk = sh.freelist[list];-
588 (void)((sh_testbit(chunk, list, sh.bittable)) ? 0 : (OPENSSL_die("assertion failed: " "sh_testbit(chunk, list, sh.bittable)", __FILE__, 586), 1));-
589 sh_setbit(chunk, list, sh.bitmalloc);-
590 sh_remove_from_list(chunk);-
591-
592 (void)((((char*)(chunk) >= sh.arena && (char*)(chunk) < &sh.arena[sh.arena_size])) ? 0 : (OPENSSL_die("assertion failed: " "WITHIN_ARENA(chunk)", __FILE__, 590), 1));-
593-
594-
595 memset(chunk, 0, sizeof(SH_LIST));-
596-
597 return
executed 3 times by 1 test: return chunk;
Executed by:
  • libcrypto.so.1.1
chunk;
executed 3 times by 1 test: return chunk;
Executed by:
  • libcrypto.so.1.1
3
598}-
599-
600static void sh_free(void *ptr)-
601{-
602 size_t list;-
603 void *buddy;-
604-
605 if (ptr ==
ptr == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
606 ((void *)0)
ptr == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
607 )-
608 return;
never executed: return;
0
609 (void)((((char*)(ptr) >= sh.arena && (char*)(ptr) < &sh.arena[sh.arena_size])) ? 0 : (OPENSSL_die("assertion failed: " "WITHIN_ARENA(ptr)", __FILE__, 605), 1));-
610 if (!((
(char*)(ptr) >= sh.arenaDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
char*)(ptr) >= sh.arena
(char*)(ptr) >= sh.arenaDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
&& (
(char*)(ptr) <...sh.arena_size]Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
char*)(ptr) < &sh.arena[sh.arena_size]
(char*)(ptr) <...sh.arena_size]Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
))
0-3
611 return;
never executed: return;
0
612-
613 list = sh_getlist(ptr);-
614 (void)((sh_testbit(ptr, list, sh.bittable)) ? 0 : (OPENSSL_die("assertion failed: " "sh_testbit(ptr, list, sh.bittable)", __FILE__, 610), 1));-
615 sh_clearbit(ptr, list, sh.bitmalloc);-
616 sh_add_to_list(&sh.freelist[list], ptr);-
617-
618-
619 while ((
(buddy = sh_fi...!= ((void *)0)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
buddy = sh_find_my_buddy(ptr, list)) !=
(buddy = sh_fi...!= ((void *)0)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3-13
620 ((void *)0)
(buddy = sh_fi...!= ((void *)0)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3-13
621 ) {-
622 (void)((ptr == sh_find_my_buddy(buddy, list)) ? 0 : (OPENSSL_die("assertion failed: " "ptr == sh_find_my_buddy(buddy, list)", __FILE__, 616), 1));-
623 (void)((ptr != -
624 ((void *)0)-
625 ) ? 0 : (OPENSSL_die("assertion failed: " "ptr != NULL", __FILE__, 617), 1));-
626 (void)((!sh_testbit(ptr, list, sh.bitmalloc)) ? 0 : (OPENSSL_die("assertion failed: " "!sh_testbit(ptr, list, sh.bitmalloc)", __FILE__, 618), 1));-
627 sh_clearbit(ptr, list, sh.bittable);-
628 sh_remove_from_list(ptr);-
629 (void)((!sh_testbit(ptr, list, sh.bitmalloc)) ? 0 : (OPENSSL_die("assertion failed: " "!sh_testbit(ptr, list, sh.bitmalloc)", __FILE__, 621), 1));-
630 sh_clearbit(buddy, list, sh.bittable);-
631 sh_remove_from_list(buddy);-
632-
633 list--;-
634-
635-
636 memset(ptr > buddy ? ptr : buddy, 0, sizeof(SH_LIST));-
637 if (ptr > buddy
ptr > buddyDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
1-12
638 ptr = buddy;
executed 12 times by 1 test: ptr = buddy;
Executed by:
  • libcrypto.so.1.1
12
639-
640 (void)((!sh_testbit(ptr, list, sh.bitmalloc)) ? 0 : (OPENSSL_die("assertion failed: " "!sh_testbit(ptr, list, sh.bitmalloc)", __FILE__, 632), 1));-
641 sh_setbit(ptr, list, sh.bittable);-
642 sh_add_to_list(&sh.freelist[list], ptr);-
643 (void)((sh.freelist[list] == ptr) ? 0 : (OPENSSL_die("assertion failed: " "sh.freelist[list] == ptr", __FILE__, 635), 1));-
644 }
executed 13 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
13
645}
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3
646-
647static size_t sh_actual_size(char *ptr)-
648{-
649 int list;-
650-
651 (void)((((char*)(ptr) >= sh.arena && (char*)(ptr) < &sh.arena[sh.arena_size])) ? 0 : (OPENSSL_die("assertion failed: " "WITHIN_ARENA(ptr)", __FILE__, 643), 1));-
652 if (!((
(char*)(ptr) >= sh.arenaDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
char*)(ptr) >= sh.arena
(char*)(ptr) >= sh.arenaDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
&& (
(char*)(ptr) <...sh.arena_size]Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
char*)(ptr) < &sh.arena[sh.arena_size]
(char*)(ptr) <...sh.arena_size]Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
))
0-6
653 return
never executed: return 0;
0;
never executed: return 0;
0
654 list = sh_getlist(ptr);-
655 (void)((sh_testbit(ptr, list, sh.bittable)) ? 0 : (OPENSSL_die("assertion failed: " "sh_testbit(ptr, list, sh.bittable)", __FILE__, 647), 1));-
656 return
executed 6 times by 1 test: return sh.arena_size / (((size_t)1) << list);
Executed by:
  • libcrypto.so.1.1
sh.arena_size / (((size_t)1) << list);
executed 6 times by 1 test: return sh.arena_size / (((size_t)1) << list);
Executed by:
  • libcrypto.so.1.1
6
657}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2