Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/mem.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | static int allow_customize = 1; | - | ||||||
4 | - | |||||||
5 | static void *(*malloc_impl)(size_t, const char *, int) | - | ||||||
6 | = CRYPTO_malloc; | - | ||||||
7 | static void *(*realloc_impl)(void *, size_t, const char *, int) | - | ||||||
8 | = CRYPTO_realloc; | - | ||||||
9 | static void (*free_impl)(void *, const char *, int) | - | ||||||
10 | = CRYPTO_free; | - | ||||||
11 | static int call_malloc_debug = 0; | - | ||||||
12 | - | |||||||
13 | - | |||||||
14 | - | |||||||
15 | - | |||||||
16 | - | |||||||
17 | int CRYPTO_set_mem_functions( | - | ||||||
18 | void *(*m)(size_t, const char *, int), | - | ||||||
19 | void *(*r)(void *, size_t, const char *, int), | - | ||||||
20 | void (*f)(void *, const char *, int)) | - | ||||||
21 | { | - | ||||||
22 | if (!allow_customize
| 0 | ||||||
23 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||
24 | if (m
| 0 | ||||||
25 | malloc_impl = m; never executed: malloc_impl = m; | 0 | ||||||
26 | if (r
| 0 | ||||||
27 | realloc_impl = r; never executed: realloc_impl = r; | 0 | ||||||
28 | if (f
| 0 | ||||||
29 | free_impl = f; never executed: free_impl = f; | 0 | ||||||
30 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||
31 | } | - | ||||||
32 | - | |||||||
33 | int CRYPTO_set_mem_debug(int flag) | - | ||||||
34 | { | - | ||||||
35 | if (!allow_customize
| 1-1908 | ||||||
36 | return executed 1908 times by 1 test: 0;return 0; Executed by:
executed 1908 times by 1 test: return 0; Executed by:
| 1908 | ||||||
37 | call_malloc_debug = flag; | - | ||||||
38 | return executed 1 time by 1 test: 1;return 1; Executed by:
executed 1 time by 1 test: return 1; Executed by:
| 1 | ||||||
39 | } | - | ||||||
40 | - | |||||||
41 | void CRYPTO_get_mem_functions( | - | ||||||
42 | void *(**m)(size_t, const char *, int), | - | ||||||
43 | void *(**r)(void *, size_t, const char *, int), | - | ||||||
44 | void (**f)(void *, const char *, int)) | - | ||||||
45 | { | - | ||||||
46 | if (m !=
| 0-368 | ||||||
47 | ((void *)0)
| 0-368 | ||||||
48 | ) | - | ||||||
49 | * executed 368 times by 1 test: m = malloc_impl;*m = malloc_impl; Executed by:
executed 368 times by 1 test: *m = malloc_impl; Executed by:
| 368 | ||||||
50 | if (r !=
| 0-368 | ||||||
51 | ((void *)0)
| 0-368 | ||||||
52 | ) | - | ||||||
53 | * executed 368 times by 1 test: r = realloc_impl;*r = realloc_impl; Executed by:
executed 368 times by 1 test: *r = realloc_impl; Executed by:
| 368 | ||||||
54 | if (f !=
| 0-368 | ||||||
55 | ((void *)0)
| 0-368 | ||||||
56 | ) | - | ||||||
57 | * executed 368 times by 1 test: f = free_impl;*f = free_impl; Executed by:
executed 368 times by 1 test: *f = free_impl; Executed by:
| 368 | ||||||
58 | } executed 368 times by 1 test: end of block Executed by:
| 368 | ||||||
59 | void *CRYPTO_malloc(size_t num, const char *file, int line) | - | ||||||
60 | { | - | ||||||
61 | void *ret = | - | ||||||
62 | ((void *)0) | - | ||||||
63 | ; | - | ||||||
64 | - | |||||||
65 | ; | - | ||||||
66 | if (malloc_impl !=
| 0-39063767 | ||||||
67 | ((void *)0)
| 0-39063767 | ||||||
68 | && malloc_impl != CRYPTO_malloc
| 0-39087280 | ||||||
69 | return never executed: malloc_impl(num, file, line);return malloc_impl(num, file, line); never executed: return malloc_impl(num, file, line); | 0 | ||||||
70 | - | |||||||
71 | if (num == 0
| 895-39044368 | ||||||
72 | return executed 895 times by 1 test: return ((void *)0) ; Executed by:
executed 895 times by 1 test: return ((void *)0) ; Executed by:
| 895 | ||||||
73 | ((void *)0) executed 895 times by 1 test: return ((void *)0) ; Executed by:
| 895 | ||||||
74 | ; executed 895 times by 1 test: return ((void *)0) ; Executed by:
| 895 | ||||||
75 | - | |||||||
76 | ; | - | ||||||
77 | if (allow_customize
| 2076-39083981 | ||||||
78 | - | |||||||
79 | - | |||||||
80 | - | |||||||
81 | - | |||||||
82 | - | |||||||
83 | allow_customize = 0; | - | ||||||
84 | } executed 2076 times by 12 tests: end of block Executed by:
| 2076 | ||||||
85 | (void)(file); (void)(line); | - | ||||||
86 | ret = malloc(num); | - | ||||||
87 | - | |||||||
88 | - | |||||||
89 | return executed 39074005 times by 12 tests: ret;return ret; Executed by:
executed 39074005 times by 12 tests: return ret; Executed by:
| 39074005 | ||||||
90 | } | - | ||||||
91 | - | |||||||
92 | void *CRYPTO_zalloc(size_t num, const char *file, int line) | - | ||||||
93 | { | - | ||||||
94 | void *ret = CRYPTO_malloc(num, file, line); | - | ||||||
95 | - | |||||||
96 | ; | - | ||||||
97 | if (ret !=
| 0-21199178 | ||||||
98 | ((void *)0)
| 0-21199178 | ||||||
99 | ) | - | ||||||
100 | memset(ret, 0, num); executed 21271141 times by 12 tests: memset(ret, 0, num); Executed by:
| 21271141 | ||||||
101 | return executed 21227378 times by 12 tests: ret;return ret; Executed by:
executed 21227378 times by 12 tests: return ret; Executed by:
| 21227378 | ||||||
102 | } | - | ||||||
103 | - | |||||||
104 | void *CRYPTO_realloc(void *str, size_t num, const char *file, int line) | - | ||||||
105 | { | - | ||||||
106 | ; | - | ||||||
107 | if (realloc_impl !=
| 0-1652109 | ||||||
108 | ((void *)0)
| 0-1652109 | ||||||
109 | && realloc_impl != &CRYPTO_realloc
| 0-1652109 | ||||||
110 | return never executed: realloc_impl(str, num, file, line);return realloc_impl(str, num, file, line); never executed: return realloc_impl(str, num, file, line); | 0 | ||||||
111 | - | |||||||
112 | ; | - | ||||||
113 | if (str ==
| 261381-1390728 | ||||||
114 | ((void *)0)
| 261381-1390728 | ||||||
115 | ) | - | ||||||
116 | return executed 1390728 times by 2 tests: CRYPTO_malloc(num, file, line);return CRYPTO_malloc(num, file, line); Executed by:
executed 1390728 times by 2 tests: return CRYPTO_malloc(num, file, line); Executed by:
| 1390728 | ||||||
117 | - | |||||||
118 | if (num == 0
| 0-261381 | ||||||
119 | CRYPTO_free(str, file, line); | - | ||||||
120 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||
121 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||
122 | ; never executed: return ((void *)0) ; | 0 | ||||||
123 | } | - | ||||||
124 | (void)(file); (void)(line); | - | ||||||
125 | - | |||||||
126 | return executed 261381 times by 11 tests: realloc(str, num);return realloc(str, num); Executed by:
executed 261381 times by 11 tests: return realloc(str, num); Executed by:
| 261381 | ||||||
127 | - | |||||||
128 | } | - | ||||||
129 | - | |||||||
130 | void *CRYPTO_clear_realloc(void *str, size_t old_len, size_t num, | - | ||||||
131 | const char *file, int line) | - | ||||||
132 | { | - | ||||||
133 | void *ret = | - | ||||||
134 | ((void *)0) | - | ||||||
135 | ; | - | ||||||
136 | - | |||||||
137 | if (str ==
| 89779-99980 | ||||||
138 | ((void *)0)
| 89779-99980 | ||||||
139 | ) | - | ||||||
140 | return executed 99980 times by 1 test: CRYPTO_malloc(num, file, line);return CRYPTO_malloc(num, file, line); Executed by:
executed 99980 times by 1 test: return CRYPTO_malloc(num, file, line); Executed by:
| 99980 | ||||||
141 | - | |||||||
142 | if (num == 0
| 0-89779 | ||||||
143 | CRYPTO_clear_free(str, old_len, file, line); | - | ||||||
144 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||
145 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||
146 | ; never executed: return ((void *)0) ; | 0 | ||||||
147 | } | - | ||||||
148 | - | |||||||
149 | - | |||||||
150 | if (num < old_len
| 0-89779 | ||||||
151 | OPENSSL_cleanse((char*)str + num, old_len - num); | - | ||||||
152 | return never executed: str;return str; never executed: return str; | 0 | ||||||
153 | } | - | ||||||
154 | - | |||||||
155 | ret = CRYPTO_malloc(num, file, line); | - | ||||||
156 | if (ret !=
| 0-89779 | ||||||
157 | ((void *)0)
| 0-89779 | ||||||
158 | ) { | - | ||||||
159 | memcpy(ret, str, old_len); | - | ||||||
160 | CRYPTO_clear_free(str, old_len, file, line); | - | ||||||
161 | } executed 89779 times by 1 test: end of block Executed by:
| 89779 | ||||||
162 | return executed 89779 times by 1 test: ret;return ret; Executed by:
executed 89779 times by 1 test: return ret; Executed by:
| 89779 | ||||||
163 | } | - | ||||||
164 | - | |||||||
165 | void CRYPTO_free(void *str, const char *file, int line) | - | ||||||
166 | { | - | ||||||
167 | ; | - | ||||||
168 | if (free_impl !=
| 0-44177933 | ||||||
169 | ((void *)0)
| 0-44177933 | ||||||
170 | && free_impl != &CRYPTO_free
| 0-44207560 | ||||||
171 | free_impl(str, file, line); | - | ||||||
172 | return; never executed: return; | 0 | ||||||
173 | } | - | ||||||
174 | free(str); | - | ||||||
175 | - | |||||||
176 | } executed 44210835 times by 12 tests: end of block Executed by:
| 44210835 | ||||||
177 | - | |||||||
178 | void CRYPTO_clear_free(void *str, size_t num, const char *file, int line) | - | ||||||
179 | { | - | ||||||
180 | if (str ==
| 302073-1330825 | ||||||
181 | ((void *)0)
| 302073-1330825 | ||||||
182 | ) | - | ||||||
183 | return; executed 302073 times by 1 test: return; Executed by:
| 302073 | ||||||
184 | if (num
| 2-1330823 | ||||||
185 | OPENSSL_cleanse(str, num); executed 1330823 times by 3 tests: OPENSSL_cleanse(str, num); Executed by:
| 1330823 | ||||||
186 | CRYPTO_free(str, file, line); | - | ||||||
187 | } executed 1330825 times by 3 tests: end of block Executed by:
| 1330825 | ||||||
Switch to Source code | Preprocessed file |