| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/ssl/bs_cbb.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | static int | - | ||||||||||||||||||
| 7 | cbb_init(CBB *cbb, uint8_t *buf, size_t cap) | - | ||||||||||||||||||
| 8 | { | - | ||||||||||||||||||
| 9 | struct cbb_buffer_st *base; | - | ||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | base = malloc(sizeof(struct cbb_buffer_st)); | - | ||||||||||||||||||
| 12 | if (base ==
| 0-1859 | ||||||||||||||||||
| 13 | ((void *)0)
| 0-1859 | ||||||||||||||||||
| 14 | ) | - | ||||||||||||||||||
| 15 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | base->buf = buf; | - | ||||||||||||||||||
| 18 | base->len = 0; | - | ||||||||||||||||||
| 19 | base->cap = cap; | - | ||||||||||||||||||
| 20 | base->can_resize = 1; | - | ||||||||||||||||||
| 21 | - | |||||||||||||||||||
| 22 | cbb->base = base; | - | ||||||||||||||||||
| 23 | cbb->is_top_level = 1; | - | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | return executed 1859 times by 9 tests: 1;return 1;Executed by:
executed 1859 times by 9 tests: return 1;Executed by:
| 1859 | ||||||||||||||||||
| 26 | } | - | ||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | int | - | ||||||||||||||||||
| 29 | CBB_init(CBB *cbb, size_t initial_capacity) | - | ||||||||||||||||||
| 30 | { | - | ||||||||||||||||||
| 31 | uint8_t *buf = | - | ||||||||||||||||||
| 32 | ((void *)0) | - | ||||||||||||||||||
| 33 | ; | - | ||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | memset(cbb, 0, sizeof(*cbb)); | - | ||||||||||||||||||
| 36 | - | |||||||||||||||||||
| 37 | if (initial_capacity == 0
| 171-586 | ||||||||||||||||||
| 38 | initial_capacity = 64; executed 171 times by 6 tests: initial_capacity = 64;Executed by:
| 171 | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | if ((
| 0-757 | ||||||||||||||||||
| 41 | ((void *)0)
| 0-757 | ||||||||||||||||||
| 42 | ) | - | ||||||||||||||||||
| 43 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | if (!cbb_init(cbb, buf, initial_capacity)
| 0-757 | ||||||||||||||||||
| 46 | free(buf); | - | ||||||||||||||||||
| 47 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 48 | } | - | ||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | return executed 757 times by 7 tests: 1;return 1;Executed by:
executed 757 times by 7 tests: return 1;Executed by:
| 757 | ||||||||||||||||||
| 51 | } | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | int | - | ||||||||||||||||||
| 54 | CBB_init_fixed(CBB *cbb, uint8_t *buf, size_t len) | - | ||||||||||||||||||
| 55 | { | - | ||||||||||||||||||
| 56 | memset(cbb, 0, sizeof(*cbb)); | - | ||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | if (!cbb_init(cbb, buf, len)
| 0-1102 | ||||||||||||||||||
| 59 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | cbb->base->can_resize = 0; | - | ||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | return executed 1102 times by 7 tests: 1;return 1;Executed by:
executed 1102 times by 7 tests: return 1;Executed by:
| 1102 | ||||||||||||||||||
| 64 | } | - | ||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | void | - | ||||||||||||||||||
| 67 | CBB_cleanup(CBB *cbb) | - | ||||||||||||||||||
| 68 | { | - | ||||||||||||||||||
| 69 | if (cbb->base
| 95-1859 | ||||||||||||||||||
| 70 | if (cbb->base->can_resize
| 757-1102 | ||||||||||||||||||
| 71 | freezero(cbb->base->buf, cbb->base->cap); executed 757 times by 7 tests: freezero(cbb->base->buf, cbb->base->cap);Executed by:
| 757 | ||||||||||||||||||
| 72 | free(cbb->base); | - | ||||||||||||||||||
| 73 | } executed 1859 times by 9 tests: end of blockExecuted by:
| 1859 | ||||||||||||||||||
| 74 | cbb->base = | - | ||||||||||||||||||
| 75 | ((void *)0) | - | ||||||||||||||||||
| 76 | ; | - | ||||||||||||||||||
| 77 | cbb->child = | - | ||||||||||||||||||
| 78 | ((void *)0) | - | ||||||||||||||||||
| 79 | ; | - | ||||||||||||||||||
| 80 | } executed 1954 times by 9 tests: end of blockExecuted by:
| 1954 | ||||||||||||||||||
| 81 | - | |||||||||||||||||||
| 82 | static int | - | ||||||||||||||||||
| 83 | cbb_buffer_add(struct cbb_buffer_st *base, uint8_t **out, size_t len) | - | ||||||||||||||||||
| 84 | { | - | ||||||||||||||||||
| 85 | size_t newlen; | - | ||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | if (base ==
| 0-11386 | ||||||||||||||||||
| 88 | ((void *)0)
| 0-11386 | ||||||||||||||||||
| 89 | ) | - | ||||||||||||||||||
| 90 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | newlen = base->len + len; | - | ||||||||||||||||||
| 93 | if (newlen < base->len
| 0-11386 | ||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | if (newlen > base->cap
| 183-11203 | ||||||||||||||||||
| 98 | size_t newcap = base->cap * 2; | - | ||||||||||||||||||
| 99 | uint8_t *newbuf; | - | ||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | if (!base->can_resize
| 2-181 | ||||||||||||||||||
| 102 | return executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 2 | ||||||||||||||||||
| 103 | - | |||||||||||||||||||
| 104 | if (newcap < base->cap
| 0-181 | ||||||||||||||||||
| 105 | newcap = newlen; executed 37 times by 5 tests: newcap = newlen;Executed by:
| 37 | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | newbuf = recallocarray(base->buf, base->cap, newcap, 1); | - | ||||||||||||||||||
| 108 | if (newbuf ==
| 0-181 | ||||||||||||||||||
| 109 | ((void *)0)
| 0-181 | ||||||||||||||||||
| 110 | ) | - | ||||||||||||||||||
| 111 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 112 | - | |||||||||||||||||||
| 113 | base->buf = newbuf; | - | ||||||||||||||||||
| 114 | base->cap = newcap; | - | ||||||||||||||||||
| 115 | } executed 181 times by 5 tests: end of blockExecuted by:
| 181 | ||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 | if (out
| 26-11358 | ||||||||||||||||||
| 118 | * executed 11358 times by 9 tests: out = base->buf + base->len;*out = base->buf + base->len;Executed by:
executed 11358 times by 9 tests: *out = base->buf + base->len;Executed by:
| 11358 | ||||||||||||||||||
| 119 | - | |||||||||||||||||||
| 120 | base->len = newlen; | - | ||||||||||||||||||
| 121 | return executed 11384 times by 9 tests: 1;return 1;Executed by:
executed 11384 times by 9 tests: return 1;Executed by:
| 11384 | ||||||||||||||||||
| 122 | } | - | ||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | static int | - | ||||||||||||||||||
| 125 | cbb_add_u(CBB *cbb, uint32_t v, size_t len_len) | - | ||||||||||||||||||
| 126 | { | - | ||||||||||||||||||
| 127 | uint8_t *buf; | - | ||||||||||||||||||
| 128 | size_t i; | - | ||||||||||||||||||
| 129 | - | |||||||||||||||||||
| 130 | if (len_len == 0
| 0-7688 | ||||||||||||||||||
| 131 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||
| 132 | - | |||||||||||||||||||
| 133 | if (len_len > 4
| 0-7688 | ||||||||||||||||||
| 134 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | if (!CBB_flush(cbb)
| 2-7685 | ||||||||||||||||||
| 137 | return executed 5 times by 1 test: 0;return 0;Executed by:
executed 5 times by 1 test: return 0;Executed by:
| 5 | ||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | for (i = len_len - 1; i < len_len
| 7683-12843 | ||||||||||||||||||
| 140 | buf[i] = v; | - | ||||||||||||||||||
| 141 | v >>= 8; | - | ||||||||||||||||||
| 142 | } executed 12843 times by 9 tests: end of blockExecuted by:
| 12843 | ||||||||||||||||||
| 143 | return executed 7683 times by 9 tests: 1;return 1;Executed by:
executed 7683 times by 9 tests: return 1;Executed by:
| 7683 | ||||||||||||||||||
| 144 | } | - | ||||||||||||||||||
| 145 | - | |||||||||||||||||||
| 146 | int | - | ||||||||||||||||||
| 147 | CBB_finish(CBB *cbb, uint8_t **out_data, size_t *out_len) | - | ||||||||||||||||||
| 148 | { | - | ||||||||||||||||||
| 149 | if (!cbb->is_top_level
| 1-1847 | ||||||||||||||||||
| 150 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | if (!CBB_flush(cbb)
| 0-1847 | ||||||||||||||||||
| 153 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | if (cbb->base->can_resize
| 0-1102 | ||||||||||||||||||
| 156 | ((void *)0)
| 0-745 | ||||||||||||||||||
| 157 | || out_len ==
| 0-745 | ||||||||||||||||||
| 158 | ((void *)0)
| 0-745 | ||||||||||||||||||
| 159 | )) | - | ||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | if (out_data !=
| 747-1100 | ||||||||||||||||||
| 167 | ((void *)0)
| 747-1100 | ||||||||||||||||||
| 168 | ) | - | ||||||||||||||||||
| 169 | * executed 747 times by 7 tests: out_data = cbb->base->buf;*out_data = cbb->base->buf;Executed by:
executed 747 times by 7 tests: *out_data = cbb->base->buf;Executed by:
| 747 | ||||||||||||||||||
| 170 | - | |||||||||||||||||||
| 171 | if (out_len !=
| 875-972 | ||||||||||||||||||
| 172 | ((void *)0)
| 875-972 | ||||||||||||||||||
| 173 | ) | - | ||||||||||||||||||
| 174 | * executed 875 times by 8 tests: out_len = cbb->base->len;*out_len = cbb->base->len;Executed by:
executed 875 times by 8 tests: *out_len = cbb->base->len;Executed by:
| 875 | ||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | cbb->base->buf = | - | ||||||||||||||||||
| 177 | ((void *)0) | - | ||||||||||||||||||
| 178 | ; | - | ||||||||||||||||||
| 179 | CBB_cleanup(cbb); | - | ||||||||||||||||||
| 180 | return executed 1847 times by 9 tests: 1;return 1;Executed by:
executed 1847 times by 9 tests: return 1;Executed by:
| 1847 | ||||||||||||||||||
| 181 | } | - | ||||||||||||||||||
| 182 | - | |||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | - | |||||||||||||||||||
| 185 | - | |||||||||||||||||||
| 186 | - | |||||||||||||||||||
| 187 | - | |||||||||||||||||||
| 188 | int | - | ||||||||||||||||||
| 189 | CBB_flush(CBB *cbb) | - | ||||||||||||||||||
| 190 | { | - | ||||||||||||||||||
| 191 | size_t child_start, i, len; | - | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | if (cbb->base ==
| 7-18091 | ||||||||||||||||||
| 194 | ((void *)0)
| 7-18091 | ||||||||||||||||||
| 195 | ) | - | ||||||||||||||||||
| 196 | return executed 7 times by 1 test: 0;return 0;Executed by:
executed 7 times by 1 test: return 0;Executed by:
| 7 | ||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | if (cbb->child ==
| 2953-15138 | ||||||||||||||||||
| 199 | ((void *)0)
| 2953-15138 | ||||||||||||||||||
| 200 | || cbb->pending_len_len == 0
| 0-2953 | ||||||||||||||||||
| 201 | return executed 15138 times by 9 tests: 1;return 1;Executed by:
executed 15138 times by 9 tests: return 1;Executed by:
| 15138 | ||||||||||||||||||
| 202 | - | |||||||||||||||||||
| 203 | child_start = cbb->offset + cbb->pending_len_len; | - | ||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | if (!CBB_flush(cbb->child)
| 0-2953 | ||||||||||||||||||
| 206 | cbb->base->len < child_start
| 0-2953 | ||||||||||||||||||
| 207 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | len = cbb->base->len - child_start; | - | ||||||||||||||||||
| 210 | - | |||||||||||||||||||
| 211 | if (cbb->pending_is_asn1
| 828-2125 | ||||||||||||||||||
| 212 | size_t len_len = 1; | - | ||||||||||||||||||
| 213 | uint8_t initial_length_byte; | - | ||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 | - | |||||||||||||||||||
| 217 | (( | - | ||||||||||||||||||
| 218 | cbb->pending_len_len == 1 | - | ||||||||||||||||||
| 219 | ) ? (void) (0) : __assert_fail ( | - | ||||||||||||||||||
| 220 | "cbb->pending_len_len == 1" | - | ||||||||||||||||||
| 221 | , __FILE__, 217, __PRETTY_FUNCTION__)) | - | ||||||||||||||||||
| 222 | ; | - | ||||||||||||||||||
| 223 | - | |||||||||||||||||||
| 224 | - | |||||||||||||||||||
| 225 | if (len > 0xfffffffe
| 0-828 | ||||||||||||||||||
| 226 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 227 | else if (len > 0xffffff
| 0-828 | ||||||||||||||||||
| 228 | len_len = 5; never executed: len_len = 5; | 0 | ||||||||||||||||||
| 229 | else if (len > 0xffff
| 2-826 | ||||||||||||||||||
| 230 | len_len = 4; executed 2 times by 1 test: len_len = 4;Executed by:
| 2 | ||||||||||||||||||
| 231 | else if (len > 0xff
| 19-807 | ||||||||||||||||||
| 232 | len_len = 3; executed 19 times by 3 tests: len_len = 3;Executed by:
| 19 | ||||||||||||||||||
| 233 | else if (len > 0x7f
| 5-802 | ||||||||||||||||||
| 234 | len_len = 2; executed 5 times by 2 tests: len_len = 2;Executed by:
| 5 | ||||||||||||||||||
| 235 | - | |||||||||||||||||||
| 236 | if (len_len == 1
| 26-802 | ||||||||||||||||||
| 237 | - | |||||||||||||||||||
| 238 | initial_length_byte = len; | - | ||||||||||||||||||
| 239 | len = 0; | - | ||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | } executed 802 times by 3 tests: else {end of blockExecuted by:
| 802 | ||||||||||||||||||
| 242 | - | |||||||||||||||||||
| 243 | - | |||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | initial_length_byte = 0x80 | (len_len - 1); | - | ||||||||||||||||||
| 247 | - | |||||||||||||||||||
| 248 | - | |||||||||||||||||||
| 249 | - | |||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 | - | |||||||||||||||||||
| 252 | size_t extra_bytes = len_len - 1; | - | ||||||||||||||||||
| 253 | if (!cbb_buffer_add(cbb->base,
| 0-26 | ||||||||||||||||||
| 254 | ((void *)0)
| 0-26 | ||||||||||||||||||
| 255 | , extra_bytes)
| 0-26 | ||||||||||||||||||
| 256 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 257 | - | |||||||||||||||||||
| 258 | memmove(cbb->base->buf + child_start + extra_bytes, | - | ||||||||||||||||||
| 259 | cbb->base->buf + child_start, len); | - | ||||||||||||||||||
| 260 | } executed 26 times by 3 tests: end of blockExecuted by:
| 26 | ||||||||||||||||||
| 261 | cbb->base->buf[cbb->offset++] = initial_length_byte; | - | ||||||||||||||||||
| 262 | cbb->pending_len_len = len_len - 1; | - | ||||||||||||||||||
| 263 | } executed 828 times by 3 tests: end of blockExecuted by:
| 828 | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | for (i = cbb->pending_len_len - 1; i < cbb->pending_len_len
| 2953-4590 | ||||||||||||||||||
| 266 | cbb->base->buf[cbb->offset + i] = len; | - | ||||||||||||||||||
| 267 | len >>= 8; | - | ||||||||||||||||||
| 268 | } executed 4590 times by 7 tests: end of blockExecuted by:
| 4590 | ||||||||||||||||||
| 269 | if (len != 0
| 0-2953 | ||||||||||||||||||
| 270 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 271 | - | |||||||||||||||||||
| 272 | cbb->child->base = | - | ||||||||||||||||||
| 273 | ((void *)0) | - | ||||||||||||||||||
| 274 | ; | - | ||||||||||||||||||
| 275 | cbb->child = | - | ||||||||||||||||||
| 276 | ((void *)0) | - | ||||||||||||||||||
| 277 | ; | - | ||||||||||||||||||
| 278 | cbb->pending_len_len = 0; | - | ||||||||||||||||||
| 279 | cbb->pending_is_asn1 = 0; | - | ||||||||||||||||||
| 280 | cbb->offset = 0; | - | ||||||||||||||||||
| 281 | - | |||||||||||||||||||
| 282 | return executed 2953 times by 7 tests: 1;return 1;Executed by:
executed 2953 times by 7 tests: return 1;Executed by:
| 2953 | ||||||||||||||||||
| 283 | } | - | ||||||||||||||||||
| 284 | - | |||||||||||||||||||
| 285 | void | - | ||||||||||||||||||
| 286 | CBB_discard_child(CBB *cbb) | - | ||||||||||||||||||
| 287 | { | - | ||||||||||||||||||
| 288 | if (cbb->child ==
| 1-4 | ||||||||||||||||||
| 289 | ((void *)0)
| 1-4 | ||||||||||||||||||
| 290 | ) | - | ||||||||||||||||||
| 291 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||
| 292 | - | |||||||||||||||||||
| 293 | cbb->base->len = cbb->offset; | - | ||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | cbb->child->base = | - | ||||||||||||||||||
| 296 | ((void *)0) | - | ||||||||||||||||||
| 297 | ; | - | ||||||||||||||||||
| 298 | cbb->child = | - | ||||||||||||||||||
| 299 | ((void *)0) | - | ||||||||||||||||||
| 300 | ; | - | ||||||||||||||||||
| 301 | cbb->pending_len_len = 0; | - | ||||||||||||||||||
| 302 | cbb->pending_is_asn1 = 0; | - | ||||||||||||||||||
| 303 | cbb->offset = 0; | - | ||||||||||||||||||
| 304 | } executed 4 times by 3 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||
| 305 | - | |||||||||||||||||||
| 306 | static int | - | ||||||||||||||||||
| 307 | cbb_add_length_prefixed(CBB *cbb, CBB *out_contents, size_t len_len) | - | ||||||||||||||||||
| 308 | { | - | ||||||||||||||||||
| 309 | uint8_t *prefix_bytes; | - | ||||||||||||||||||
| 310 | - | |||||||||||||||||||
| 311 | if (!CBB_flush(cbb)
| 2-2130 | ||||||||||||||||||
| 312 | return executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 2 | ||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | cbb->offset = cbb->base->len; | - | ||||||||||||||||||
| 315 | if (!cbb_buffer_add(cbb->base, &prefix_bytes, len_len)
| 0-2130 | ||||||||||||||||||
| 316 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | memset(prefix_bytes, 0, len_len); | - | ||||||||||||||||||
| 319 | memset(out_contents, 0, sizeof(CBB)); | - | ||||||||||||||||||
| 320 | out_contents->base = cbb->base; | - | ||||||||||||||||||
| 321 | cbb->child = out_contents; | - | ||||||||||||||||||
| 322 | cbb->pending_len_len = len_len; | - | ||||||||||||||||||
| 323 | cbb->pending_is_asn1 = 0; | - | ||||||||||||||||||
| 324 | - | |||||||||||||||||||
| 325 | return executed 2130 times by 6 tests: 1;return 1;Executed by:
executed 2130 times by 6 tests: return 1;Executed by:
| 2130 | ||||||||||||||||||
| 326 | } | - | ||||||||||||||||||
| 327 | - | |||||||||||||||||||
| 328 | int | - | ||||||||||||||||||
| 329 | CBB_add_u8_length_prefixed(CBB *cbb, CBB *out_contents) | - | ||||||||||||||||||
| 330 | { | - | ||||||||||||||||||
| 331 | return executed 452 times by 6 tests: cbb_add_length_prefixed(cbb, out_contents, 1);return cbb_add_length_prefixed(cbb, out_contents, 1);Executed by:
executed 452 times by 6 tests: return cbb_add_length_prefixed(cbb, out_contents, 1);Executed by:
| 452 | ||||||||||||||||||
| 332 | } | - | ||||||||||||||||||
| 333 | - | |||||||||||||||||||
| 334 | int | - | ||||||||||||||||||
| 335 | CBB_add_u16_length_prefixed(CBB *cbb, CBB *out_contents) | - | ||||||||||||||||||
| 336 | { | - | ||||||||||||||||||
| 337 | return executed 939 times by 6 tests: cbb_add_length_prefixed(cbb, out_contents, 2);return cbb_add_length_prefixed(cbb, out_contents, 2);Executed by:
executed 939 times by 6 tests: return cbb_add_length_prefixed(cbb, out_contents, 2);Executed by:
| 939 | ||||||||||||||||||
| 338 | } | - | ||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | int | - | ||||||||||||||||||
| 341 | CBB_add_u24_length_prefixed(CBB *cbb, CBB *out_contents) | - | ||||||||||||||||||
| 342 | { | - | ||||||||||||||||||
| 343 | return executed 741 times by 5 tests: cbb_add_length_prefixed(cbb, out_contents, 3);return cbb_add_length_prefixed(cbb, out_contents, 3);Executed by:
executed 741 times by 5 tests: return cbb_add_length_prefixed(cbb, out_contents, 3);Executed by:
| 741 | ||||||||||||||||||
| 344 | } | - | ||||||||||||||||||
| 345 | - | |||||||||||||||||||
| 346 | int | - | ||||||||||||||||||
| 347 | CBB_add_asn1(CBB *cbb, CBB *out_contents, unsigned int tag) | - | ||||||||||||||||||
| 348 | { | - | ||||||||||||||||||
| 349 | if (tag >
| 0-833 | ||||||||||||||||||
| 350 | (255)
| 0-833 | ||||||||||||||||||
| 351 | ) | - | ||||||||||||||||||
| 352 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | - | |||||||||||||||||||
| 355 | if ((
| 0-833 | ||||||||||||||||||
| 356 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | - | |||||||||||||||||||
| 359 | if (!CBB_flush(cbb)
| 0-832 | ||||||||||||||||||
| 360 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||
| 361 | - | |||||||||||||||||||
| 362 | - | |||||||||||||||||||
| 363 | - | |||||||||||||||||||
| 364 | - | |||||||||||||||||||
| 365 | - | |||||||||||||||||||
| 366 | cbb->offset = cbb->base->len; | - | ||||||||||||||||||
| 367 | if (!CBB_add_u8(cbb, 0)
| 0-832 | ||||||||||||||||||
| 368 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 369 | - | |||||||||||||||||||
| 370 | memset(out_contents, 0, sizeof(CBB)); | - | ||||||||||||||||||
| 371 | out_contents->base = cbb->base; | - | ||||||||||||||||||
| 372 | cbb->child = out_contents; | - | ||||||||||||||||||
| 373 | cbb->pending_len_len = 1; | - | ||||||||||||||||||
| 374 | cbb->pending_is_asn1 = 1; | - | ||||||||||||||||||
| 375 | - | |||||||||||||||||||
| 376 | return executed 832 times by 3 tests: 1;return 1;Executed by:
executed 832 times by 3 tests: return 1;Executed by:
| 832 | ||||||||||||||||||
| 377 | } | - | ||||||||||||||||||
| 378 | - | |||||||||||||||||||
| 379 | int | - | ||||||||||||||||||
| 380 | CBB_add_bytes(CBB *cbb, const uint8_t *data, size_t len) | - | ||||||||||||||||||
| 381 | { | - | ||||||||||||||||||
| 382 | uint8_t *dest; | - | ||||||||||||||||||
| 383 | - | |||||||||||||||||||
| 384 | if (!CBB_add_space(cbb, &dest, len)
| 1-1148 | ||||||||||||||||||
| 385 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||
| 386 | - | |||||||||||||||||||
| 387 | memcpy(dest, data, len); | - | ||||||||||||||||||
| 388 | return executed 1148 times by 7 tests: 1;return 1;Executed by:
executed 1148 times by 7 tests: return 1;Executed by:
| 1148 | ||||||||||||||||||
| 389 | } | - | ||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | int | - | ||||||||||||||||||
| 392 | CBB_add_space(CBB *cbb, uint8_t **out_data, size_t len) | - | ||||||||||||||||||
| 393 | { | - | ||||||||||||||||||
| 394 | if (!CBB_flush(cbb)
| 0-1545 | ||||||||||||||||||
| 395 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||
| 396 | - | |||||||||||||||||||
| 397 | return executed 1545 times by 7 tests: 1;return 1;Executed by:
executed 1545 times by 7 tests: return 1;Executed by:
| 1545 | ||||||||||||||||||
| 398 | } | - | ||||||||||||||||||
| 399 | - | |||||||||||||||||||
| 400 | int | - | ||||||||||||||||||
| 401 | CBB_add_u8(CBB *cbb, size_t value) | - | ||||||||||||||||||
| 402 | { | - | ||||||||||||||||||
| 403 | if (value >
| 0-3570 | ||||||||||||||||||
| 404 | (255)
| 0-3570 | ||||||||||||||||||
| 405 | ) | - | ||||||||||||||||||
| 406 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | return executed 3570 times by 7 tests: cbb_add_u(cbb, (uint32_t)value, 1);return cbb_add_u(cbb, (uint32_t)value, 1);Executed by:
executed 3570 times by 7 tests: return cbb_add_u(cbb, (uint32_t)value, 1);Executed by:
| 3570 | ||||||||||||||||||
| 409 | } | - | ||||||||||||||||||
| 410 | - | |||||||||||||||||||
| 411 | int | - | ||||||||||||||||||
| 412 | CBB_add_u16(CBB *cbb, size_t value) | - | ||||||||||||||||||
| 413 | { | - | ||||||||||||||||||
| 414 | if (value >
| 0-3133 | ||||||||||||||||||
| 415 | (65535)
| 0-3133 | ||||||||||||||||||
| 416 | ) | - | ||||||||||||||||||
| 417 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 418 | - | |||||||||||||||||||
| 419 | return executed 3133 times by 9 tests: cbb_add_u(cbb, (uint32_t)value, 2);return cbb_add_u(cbb, (uint32_t)value, 2);Executed by:
executed 3133 times by 9 tests: return cbb_add_u(cbb, (uint32_t)value, 2);Executed by:
| 3133 | ||||||||||||||||||
| 420 | } | - | ||||||||||||||||||
| 421 | - | |||||||||||||||||||
| 422 | int | - | ||||||||||||||||||
| 423 | CBB_add_u24(CBB *cbb, size_t value) | - | ||||||||||||||||||
| 424 | { | - | ||||||||||||||||||
| 425 | if (value > 0xffffffUL
| 0-925 | ||||||||||||||||||
| 426 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 427 | - | |||||||||||||||||||
| 428 | return executed 925 times by 3 tests: cbb_add_u(cbb, (uint32_t)value, 3);return cbb_add_u(cbb, (uint32_t)value, 3);Executed by:
executed 925 times by 3 tests: return cbb_add_u(cbb, (uint32_t)value, 3);Executed by:
| 925 | ||||||||||||||||||
| 429 | } | - | ||||||||||||||||||
| 430 | - | |||||||||||||||||||
| 431 | int | - | ||||||||||||||||||
| 432 | CBB_add_u32(CBB *cbb, size_t value) | - | ||||||||||||||||||
| 433 | { | - | ||||||||||||||||||
| 434 | if (value > 0xffffffffUL
| 0-60 | ||||||||||||||||||
| 435 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 436 | - | |||||||||||||||||||
| 437 | return executed 60 times by 2 tests: cbb_add_u(cbb, (uint32_t)value, 4);return cbb_add_u(cbb, (uint32_t)value, 4);Executed by:
executed 60 times by 2 tests: return cbb_add_u(cbb, (uint32_t)value, 4);Executed by:
| 60 | ||||||||||||||||||
| 438 | } | - | ||||||||||||||||||
| 439 | - | |||||||||||||||||||
| 440 | int | - | ||||||||||||||||||
| 441 | CBB_add_asn1_uint64(CBB *cbb, uint64_t value) | - | ||||||||||||||||||
| 442 | { | - | ||||||||||||||||||
| 443 | CBB child; | - | ||||||||||||||||||
| 444 | size_t i; | - | ||||||||||||||||||
| 445 | int started = 0; | - | ||||||||||||||||||
| 446 | - | |||||||||||||||||||
| 447 | if (!CBB_add_asn1(cbb, &child, (0x00 | 0x00 | 0x2))
| 0-268 | ||||||||||||||||||
| 448 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 449 | - | |||||||||||||||||||
| 450 | for (i = 0; i < 8
| 268-2144 | ||||||||||||||||||
| 451 | uint8_t byte = (value >> 8 * (7 - i)) & 0xff; | - | ||||||||||||||||||
| 452 | if (!started
| 332-1812 | ||||||||||||||||||
| 453 | if (byte == 0
| 267-1545 | ||||||||||||||||||
| 454 | - | |||||||||||||||||||
| 455 | continue; executed 1545 times by 3 tests: continue;Executed by:
| 1545 | ||||||||||||||||||
| 456 | - | |||||||||||||||||||
| 457 | - | |||||||||||||||||||
| 458 | - | |||||||||||||||||||
| 459 | - | |||||||||||||||||||
| 460 | - | |||||||||||||||||||
| 461 | if ((
| 0-253 | ||||||||||||||||||
| 462 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 463 | - | |||||||||||||||||||
| 464 | started = 1; | - | ||||||||||||||||||
| 465 | } executed 267 times by 3 tests: end of blockExecuted by:
| 267 | ||||||||||||||||||
| 466 | if (!CBB_add_u8(&child, byte)
| 0-599 | ||||||||||||||||||
| 467 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 468 | } executed 599 times by 3 tests: end of blockExecuted by:
| 599 | ||||||||||||||||||
| 469 | - | |||||||||||||||||||
| 470 | - | |||||||||||||||||||
| 471 | if (!started
| 0-267 | ||||||||||||||||||
| 472 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 473 | - | |||||||||||||||||||
| 474 | return executed 268 times by 3 tests: CBB_flush(cbb);return CBB_flush(cbb);Executed by:
executed 268 times by 3 tests: return CBB_flush(cbb);Executed by:
| 268 | ||||||||||||||||||
| 475 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |