Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/buffer/buffer.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | BUF_MEM *BUF_MEM_new_ex(unsigned long flags) | - | ||||||||||||
2 | { | - | ||||||||||||
3 | BUF_MEM *ret; | - | ||||||||||||
4 | - | |||||||||||||
5 | ret = BUF_MEM_new(); | - | ||||||||||||
6 | if (ret !=
| 0-111695 | ||||||||||||
7 | ((void *)0)
| 0-111695 | ||||||||||||
8 | ) | - | ||||||||||||
9 | ret->flags = flags; executed 111695 times by 1 test: ret->flags = flags; Executed by:
| 111695 | ||||||||||||
10 | return executed 111695 times by 1 test: ret;return ret; Executed by:
executed 111695 times by 1 test: return ret; Executed by:
| 111695 | ||||||||||||
11 | } | - | ||||||||||||
12 | - | |||||||||||||
13 | BUF_MEM *BUF_MEM_new(void) | - | ||||||||||||
14 | { | - | ||||||||||||
15 | BUF_MEM *ret; | - | ||||||||||||
16 | - | |||||||||||||
17 | ret = CRYPTO_zalloc(sizeof(*ret), __FILE__, 35); | - | ||||||||||||
18 | if (ret ==
| 0-520915 | ||||||||||||
19 | ((void *)0)
| 0-520915 | ||||||||||||
20 | ) { | - | ||||||||||||
21 | ERR_put_error(7,(101),((1|64)),__FILE__,37); | - | ||||||||||||
22 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
23 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
24 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
25 | } | - | ||||||||||||
26 | return executed 520915 times by 1 test: ret;return ret; Executed by:
executed 520915 times by 1 test: return ret; Executed by:
| 520915 | ||||||||||||
27 | } | - | ||||||||||||
28 | - | |||||||||||||
29 | void BUF_MEM_free(BUF_MEM *a) | - | ||||||||||||
30 | { | - | ||||||||||||
31 | if (a ==
| 48617-400405 | ||||||||||||
32 | ((void *)0)
| 48617-400405 | ||||||||||||
33 | ) | - | ||||||||||||
34 | return; executed 48617 times by 1 test: return; Executed by:
| 48617 | ||||||||||||
35 | if (a->data !=
| 185075-215330 | ||||||||||||
36 | ((void *)0)
| 185075-215330 | ||||||||||||
37 | ) { | - | ||||||||||||
38 | if (a->flags & 0x01
| 7751-177324 | ||||||||||||
39 | CRYPTO_secure_clear_free(a->data, a->max, __FILE__, 49); executed 7751 times by 1 test: CRYPTO_secure_clear_free(a->data, a->max, __FILE__, 49); Executed by:
| 7751 | ||||||||||||
40 | else | - | ||||||||||||
41 | CRYPTO_clear_free(a->data, a->max, __FILE__, 51); executed 177324 times by 1 test: CRYPTO_clear_free(a->data, a->max, __FILE__, 51); Executed by:
| 177324 | ||||||||||||
42 | } | - | ||||||||||||
43 | CRYPTO_free(a, __FILE__, 53); | - | ||||||||||||
44 | } executed 400405 times by 1 test: end of block Executed by:
| 400405 | ||||||||||||
45 | - | |||||||||||||
46 | - | |||||||||||||
47 | - | |||||||||||||
48 | static char *sec_alloc_realloc(BUF_MEM *str, size_t len) | - | ||||||||||||
49 | { | - | ||||||||||||
50 | char *ret; | - | ||||||||||||
51 | - | |||||||||||||
52 | ret = CRYPTO_secure_malloc(len, __FILE__, 62); | - | ||||||||||||
53 | if (str->data !=
| 7751-33012 | ||||||||||||
54 | ((void *)0)
| 7751-33012 | ||||||||||||
55 | ) { | - | ||||||||||||
56 | if (ret !=
| 0-33012 | ||||||||||||
57 | ((void *)0)
| 0-33012 | ||||||||||||
58 | ) { | - | ||||||||||||
59 | memcpy(ret, str->data, str->length); | - | ||||||||||||
60 | CRYPTO_secure_clear_free(str->data, str->length, __FILE__, 66); | - | ||||||||||||
61 | str->data = | - | ||||||||||||
62 | ((void *)0) | - | ||||||||||||
63 | ; | - | ||||||||||||
64 | } executed 33012 times by 1 test: end of block Executed by:
| 33012 | ||||||||||||
65 | } executed 33012 times by 1 test: end of block Executed by:
| 33012 | ||||||||||||
66 | return executed 40763 times by 1 test: ret;return ret; Executed by:
executed 40763 times by 1 test: return ret; Executed by:
| 40763 | ||||||||||||
67 | } | - | ||||||||||||
68 | - | |||||||||||||
69 | size_t BUF_MEM_grow(BUF_MEM *str, size_t len) | - | ||||||||||||
70 | { | - | ||||||||||||
71 | char *ret; | - | ||||||||||||
72 | size_t n; | - | ||||||||||||
73 | - | |||||||||||||
74 | if (str->length >= len
| 168621-279011 | ||||||||||||
75 | str->length = len; | - | ||||||||||||
76 | return executed 168621 times by 1 test: len;return len; Executed by:
executed 168621 times by 1 test: return len; Executed by:
| 168621 | ||||||||||||
77 | } | - | ||||||||||||
78 | if (str->max >= len
| 18361-260650 | ||||||||||||
79 | if (str->data !=
| 0-18361 | ||||||||||||
80 | ((void *)0)
| 0-18361 | ||||||||||||
81 | ) | - | ||||||||||||
82 | memset(&str->data[str->length], 0, len - str->length); executed 18361 times by 1 test: memset(&str->data[str->length], 0, len - str->length); Executed by:
| 18361 | ||||||||||||
83 | str->length = len; | - | ||||||||||||
84 | return executed 18361 times by 1 test: len;return len; Executed by:
executed 18361 times by 1 test: return len; Executed by:
| 18361 | ||||||||||||
85 | } | - | ||||||||||||
86 | - | |||||||||||||
87 | if (len > 0x5ffffffc
| 0-260650 | ||||||||||||
88 | ERR_put_error(7,(100),((1|64)),__FILE__,90); | - | ||||||||||||
89 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
90 | } | - | ||||||||||||
91 | n = (len + 3) / 3 * 4; | - | ||||||||||||
92 | if ((
| 0-260650 | ||||||||||||
93 | ret = sec_alloc_realloc(str, n); never executed: ret = sec_alloc_realloc(str, n); | 0 | ||||||||||||
94 | else | - | ||||||||||||
95 | ret = CRYPTO_realloc(str->data, n, __FILE__, 97); executed 260650 times by 1 test: ret = CRYPTO_realloc(str->data, n, __FILE__, 97); Executed by:
| 260650 | ||||||||||||
96 | if (ret ==
| 0-260650 | ||||||||||||
97 | ((void *)0)
| 0-260650 | ||||||||||||
98 | ) { | - | ||||||||||||
99 | ERR_put_error(7,(100),((1|64)),__FILE__,99); | - | ||||||||||||
100 | len = 0; | - | ||||||||||||
101 | } never executed: else {end of block | 0 | ||||||||||||
102 | str->data = ret; | - | ||||||||||||
103 | str->max = n; | - | ||||||||||||
104 | memset(&str->data[str->length], 0, len - str->length); | - | ||||||||||||
105 | str->length = len; | - | ||||||||||||
106 | } executed 260650 times by 1 test: end of block Executed by:
| 260650 | ||||||||||||
107 | return executed 260650 times by 1 test: len;return len; Executed by:
executed 260650 times by 1 test: return len; Executed by:
| 260650 | ||||||||||||
108 | } | - | ||||||||||||
109 | - | |||||||||||||
110 | size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len) | - | ||||||||||||
111 | { | - | ||||||||||||
112 | char *ret; | - | ||||||||||||
113 | size_t n; | - | ||||||||||||
114 | - | |||||||||||||
115 | if (str->length >= len
| 25688-1016139 | ||||||||||||
116 | if (str->data !=
| 0-25688 | ||||||||||||
117 | ((void *)0)
| 0-25688 | ||||||||||||
118 | ) | - | ||||||||||||
119 | memset(&str->data[len], 0, str->length - len); executed 25688 times by 1 test: memset(&str->data[len], 0, str->length - len); Executed by:
| 25688 | ||||||||||||
120 | str->length = len; | - | ||||||||||||
121 | return executed 25688 times by 1 test: len;return len; Executed by:
executed 25688 times by 1 test: return len; Executed by:
| 25688 | ||||||||||||
122 | } | - | ||||||||||||
123 | if (str->max >= len
| 230510-785629 | ||||||||||||
124 | memset(&str->data[str->length], 0, len - str->length); | - | ||||||||||||
125 | str->length = len; | - | ||||||||||||
126 | return executed 785629 times by 1 test: len;return len; Executed by:
executed 785629 times by 1 test: return len; Executed by:
| 785629 | ||||||||||||
127 | } | - | ||||||||||||
128 | - | |||||||||||||
129 | if (len > 0x5ffffffc
| 0-230510 | ||||||||||||
130 | ERR_put_error(7,(105),((1|64)),__FILE__,128); | - | ||||||||||||
131 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
132 | } | - | ||||||||||||
133 | n = (len + 3) / 3 * 4; | - | ||||||||||||
134 | if ((
| 40763-189747 | ||||||||||||
135 | ret = sec_alloc_realloc(str, n); executed 40763 times by 1 test: ret = sec_alloc_realloc(str, n); Executed by:
| 40763 | ||||||||||||
136 | else | - | ||||||||||||
137 | ret = CRYPTO_clear_realloc(str->data, str->max, n, __FILE__, 135); executed 189747 times by 1 test: ret = CRYPTO_clear_realloc(str->data, str->max, n, __FILE__, 135); Executed by:
| 189747 | ||||||||||||
138 | if (ret ==
| 0-230510 | ||||||||||||
139 | ((void *)0)
| 0-230510 | ||||||||||||
140 | ) { | - | ||||||||||||
141 | ERR_put_error(7,(105),((1|64)),__FILE__,137); | - | ||||||||||||
142 | len = 0; | - | ||||||||||||
143 | } never executed: else {end of block | 0 | ||||||||||||
144 | str->data = ret; | - | ||||||||||||
145 | str->max = n; | - | ||||||||||||
146 | memset(&str->data[str->length], 0, len - str->length); | - | ||||||||||||
147 | str->length = len; | - | ||||||||||||
148 | } executed 230510 times by 1 test: end of block Executed by:
| 230510 | ||||||||||||
149 | return executed 230510 times by 1 test: len;return len; Executed by:
executed 230510 times by 1 test: return len; Executed by:
| 230510 | ||||||||||||
150 | } | - | ||||||||||||
151 | - | |||||||||||||
152 | void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size) | - | ||||||||||||
153 | { | - | ||||||||||||
154 | size_t i; | - | ||||||||||||
155 | if (in
| 3-123 | ||||||||||||
156 | out += size - 1; | - | ||||||||||||
157 | for (i = 0; i < size
| 3-24 | ||||||||||||
158 | * executed 24 times by 1 test: out-- = *in++;*out-- = *in++; Executed by:
executed 24 times by 1 test: *out-- = *in++; Executed by:
| 24 | ||||||||||||
159 | } executed 3 times by 1 test: else {end of block Executed by:
| 3 | ||||||||||||
160 | unsigned char *q; | - | ||||||||||||
161 | char c; | - | ||||||||||||
162 | q = out + size - 1; | - | ||||||||||||
163 | for (i = 0; i < size / 2
| 123-348 | ||||||||||||
164 | c = *q; | - | ||||||||||||
165 | *q-- = *out; | - | ||||||||||||
166 | *out++ = c; | - | ||||||||||||
167 | } executed 348 times by 1 test: end of block Executed by:
| 348 | ||||||||||||
168 | } executed 123 times by 1 test: end of block Executed by:
| 123 | ||||||||||||
169 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |