Coverage Report

Created: 2025-12-14 06:56

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libcbor/src/cbor/streaming.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2014-2020 Pavel Kalvoda <me@pavelkalvoda.com>
3
 *
4
 * libcbor is free software; you can redistribute it and/or modify
5
 * it under the terms of the MIT license. See LICENSE for details.
6
 */
7
8
#include "streaming.h"
9
#include "internal/loaders.h"
10
11
static bool claim_bytes(size_t required, size_t provided,
12
15.0M
                        struct cbor_decoder_result *result) {
13
15.0M
  if (required > (provided - result->read)) {
14
21.6k
    result->required = required + result->read;
15
21.6k
    result->read = 0;
16
21.6k
    result->status = CBOR_DECODER_NEDATA;
17
21.6k
    return false;
18
15.0M
  } else {
19
15.0M
    result->read += required;
20
15.0M
    result->required = 0;
21
15.0M
    return true;
22
15.0M
  }
23
15.0M
}
24
25
// Use implicit capture as an exception to avoid the super long parameter list
26
#define CLAIM_BYTES_AND_INVOKE(callback_name, length, source_extra_offset) \
27
1.14M
  do {                                                                     \
28
1.14M
    if (claim_bytes(length, source_size, &result)) {                       \
29
1.13M
      callbacks->callback_name(context, source + 1 + source_extra_offset,  \
30
1.13M
                               length);                                    \
31
1.13M
    }                                                                      \
32
1.14M
  } while (0)
33
34
#define READ_CLAIM_INVOKE(callback_name, length_reader, length_bytes) \
35
134k
  do {                                                                \
36
134k
    if (claim_bytes(length_bytes, source_size, &result)) {            \
37
130k
      uint64_t length = length_reader(source + 1);                    \
38
130k
      CLAIM_BYTES_AND_INVOKE(callback_name, length, length_bytes);    \
39
130k
    }                                                                 \
40
134k
    return result;                                                    \
41
134k
  } while (0)
42
43
struct cbor_decoder_result cbor_stream_decode(
44
    cbor_data source, size_t source_size,
45
13.1M
    const struct cbor_callbacks *callbacks, void *context) {
46
  // Attempt to claim the initial MTB byte
47
13.1M
  struct cbor_decoder_result result = {.status = CBOR_DECODER_FINISHED};
48
13.1M
  if (!claim_bytes(1, source_size, &result)) {
49
0
    return result;
50
0
  }
51
52
13.1M
  switch (*source) {
53
2.72M
    case 0x00: /* Fallthrough */
54
2.90M
    case 0x01: /* Fallthrough */
55
2.93M
    case 0x02: /* Fallthrough */
56
3.01M
    case 0x03: /* Fallthrough */
57
3.31M
    case 0x04: /* Fallthrough */
58
3.33M
    case 0x05: /* Fallthrough */
59
3.42M
    case 0x06: /* Fallthrough */
60
3.52M
    case 0x07: /* Fallthrough */
61
3.58M
    case 0x08: /* Fallthrough */
62
3.64M
    case 0x09: /* Fallthrough */
63
3.66M
    case 0x0A: /* Fallthrough */
64
3.87M
    case 0x0B: /* Fallthrough */
65
3.89M
    case 0x0C: /* Fallthrough */
66
3.92M
    case 0x0D: /* Fallthrough */
67
4.01M
    case 0x0E: /* Fallthrough */
68
4.06M
    case 0x0F: /* Fallthrough */
69
4.09M
    case 0x10: /* Fallthrough */
70
4.12M
    case 0x11: /* Fallthrough */
71
4.14M
    case 0x12: /* Fallthrough */
72
4.17M
    case 0x13: /* Fallthrough */
73
4.30M
    case 0x14: /* Fallthrough */
74
4.32M
    case 0x15: /* Fallthrough */
75
4.34M
    case 0x16: /* Fallthrough */
76
4.39M
    case 0x17:
77
      /* Embedded one byte unsigned integer */
78
4.39M
      {
79
4.39M
        callbacks->uint8(context, _cbor_load_uint8(source));
80
4.39M
        return result;
81
4.34M
      }
82
349k
    case 0x18:
83
      /* One byte unsigned integer */
84
349k
      {
85
349k
        if (claim_bytes(1, source_size, &result)) {
86
348k
          callbacks->uint8(context, _cbor_load_uint8(source + 1));
87
348k
        }
88
349k
        return result;
89
4.34M
      }
90
41.1k
    case 0x19:
91
      /* Two bytes unsigned integer */
92
41.1k
      {
93
41.1k
        if (claim_bytes(2, source_size, &result)) {
94
40.6k
          callbacks->uint16(context, _cbor_load_uint16(source + 1));
95
40.6k
        }
96
41.1k
        return result;
97
4.34M
      }
98
9.13k
    case 0x1A:
99
      /* Four bytes unsigned integer */
100
9.13k
      {
101
9.13k
        if (claim_bytes(4, source_size, &result)) {
102
8.72k
          callbacks->uint32(context, _cbor_load_uint32(source + 1));
103
8.72k
        }
104
9.13k
        return result;
105
4.34M
      }
106
11.4k
    case 0x1B:
107
      /* Eight bytes unsigned integer */
108
11.4k
      {
109
11.4k
        if (claim_bytes(8, source_size, &result)) {
110
11.0k
          callbacks->uint64(context, _cbor_load_uint64(source + 1));
111
11.0k
        }
112
11.4k
        return result;
113
4.34M
      }
114
688
    case 0x1C: /* Fallthrough */
115
1.13k
    case 0x1D: /* Fallthrough */
116
1.55k
    case 0x1E: /* Fallthrough */
117
2.08k
    case 0x1F:
118
      /* Reserved */
119
2.08k
      { return (struct cbor_decoder_result){.status = CBOR_DECODER_ERROR}; }
120
9.57k
    case 0x20: /* Fallthrough */
121
25.2k
    case 0x21: /* Fallthrough */
122
29.2k
    case 0x22: /* Fallthrough */
123
34.7k
    case 0x23: /* Fallthrough */
124
41.3k
    case 0x24: /* Fallthrough */
125
48.8k
    case 0x25: /* Fallthrough */
126
56.4k
    case 0x26: /* Fallthrough */
127
93.1k
    case 0x27: /* Fallthrough */
128
97.9k
    case 0x28: /* Fallthrough */
129
105k
    case 0x29: /* Fallthrough */
130
117k
    case 0x2A: /* Fallthrough */
131
131k
    case 0x2B: /* Fallthrough */
132
142k
    case 0x2C: /* Fallthrough */
133
176k
    case 0x2D: /* Fallthrough */
134
198k
    case 0x2E: /* Fallthrough */
135
236k
    case 0x2F: /* Fallthrough */
136
351k
    case 0x30: /* Fallthrough */
137
370k
    case 0x31: /* Fallthrough */
138
389k
    case 0x32: /* Fallthrough */
139
477k
    case 0x33: /* Fallthrough */
140
493k
    case 0x34: /* Fallthrough */
141
507k
    case 0x35: /* Fallthrough */
142
519k
    case 0x36: /* Fallthrough */
143
532k
    case 0x37:
144
      /* Embedded one byte negative integer */
145
532k
      {
146
532k
        callbacks->negint8(context,
147
532k
                           _cbor_load_uint8(source) - 0x20); /* 0x20 offset */
148
532k
        return result;
149
519k
      }
150
17.8k
    case 0x38:
151
      /* One byte negative integer */
152
17.8k
      {
153
17.8k
        if (claim_bytes(1, source_size, &result)) {
154
17.4k
          callbacks->negint8(context, _cbor_load_uint8(source + 1));
155
17.4k
        }
156
17.8k
        return result;
157
519k
      }
158
26.4k
    case 0x39:
159
      /* Two bytes negative integer */
160
26.4k
      {
161
26.4k
        if (claim_bytes(2, source_size, &result)) {
162
26.0k
          callbacks->negint16(context, _cbor_load_uint16(source + 1));
163
26.0k
        }
164
26.4k
        return result;
165
519k
      }
166
8.86k
    case 0x3A:
167
      /* Four bytes negative integer */
168
8.86k
      {
169
8.86k
        if (claim_bytes(4, source_size, &result)) {
170
8.36k
          callbacks->negint32(context, _cbor_load_uint32(source + 1));
171
8.36k
        }
172
8.86k
        return result;
173
519k
      }
174
16.3k
    case 0x3B:
175
      /* Eight bytes negative integer */
176
16.3k
      {
177
16.3k
        if (claim_bytes(8, source_size, &result)) {
178
15.9k
          callbacks->negint64(context, _cbor_load_uint64(source + 1));
179
15.9k
        }
180
16.3k
        return result;
181
519k
      }
182
444
    case 0x3C: /* Fallthrough */
183
908
    case 0x3D: /* Fallthrough */
184
1.40k
    case 0x3E: /* Fallthrough */
185
2.04k
    case 0x3F:
186
      /* Reserved */
187
2.04k
      { return (struct cbor_decoder_result){.status = CBOR_DECODER_ERROR}; }
188
97.5k
    case 0x40: /* Fallthrough */
189
107k
    case 0x41: /* Fallthrough */
190
115k
    case 0x42: /* Fallthrough */
191
207k
    case 0x43: /* Fallthrough */
192
220k
    case 0x44: /* Fallthrough */
193
225k
    case 0x45: /* Fallthrough */
194
233k
    case 0x46: /* Fallthrough */
195
237k
    case 0x47: /* Fallthrough */
196
244k
    case 0x48: /* Fallthrough */
197
245k
    case 0x49: /* Fallthrough */
198
247k
    case 0x4A: /* Fallthrough */
199
250k
    case 0x4B: /* Fallthrough */
200
252k
    case 0x4C: /* Fallthrough */
201
257k
    case 0x4D: /* Fallthrough */
202
258k
    case 0x4E: /* Fallthrough */
203
263k
    case 0x4F: /* Fallthrough */
204
278k
    case 0x50: /* Fallthrough */
205
280k
    case 0x51: /* Fallthrough */
206
283k
    case 0x52: /* Fallthrough */
207
300k
    case 0x53: /* Fallthrough */
208
351k
    case 0x54: /* Fallthrough */
209
359k
    case 0x55: /* Fallthrough */
210
361k
    case 0x56: /* Fallthrough */
211
362k
    case 0x57:
212
      /* Embedded length byte string */
213
362k
      {
214
362k
        uint64_t length = _cbor_load_uint8(source) - 0x40; /* 0x40 offset */
215
362k
        CLAIM_BYTES_AND_INVOKE(byte_string, length, 0);
216
362k
        return result;
217
361k
      }
218
107k
    case 0x58:
219
      /* One byte length byte string */
220
107k
      READ_CLAIM_INVOKE(byte_string, _cbor_load_uint8, 1);
221
3.38k
    case 0x59:
222
      /* Two bytes length byte string */
223
3.38k
      READ_CLAIM_INVOKE(byte_string, _cbor_load_uint16, 2);
224
2.11k
    case 0x5A:
225
      /* Four bytes length byte string */
226
2.11k
      READ_CLAIM_INVOKE(byte_string, _cbor_load_uint32, 4);
227
2.92k
    case 0x5B:
228
      /* Eight bytes length byte string */
229
2.92k
      READ_CLAIM_INVOKE(byte_string, _cbor_load_uint64, 8);
230
441
    case 0x5C: /* Fallthrough */
231
886
    case 0x5D: /* Fallthrough */
232
1.39k
    case 0x5E:
233
      /* Reserved */
234
1.39k
      { return (struct cbor_decoder_result){.status = CBOR_DECODER_ERROR}; }
235
12.3k
    case 0x5F:
236
      /* Indefinite byte string */
237
12.3k
      {
238
12.3k
        callbacks->byte_string_start(context);
239
12.3k
        return result;
240
886
      }
241
168k
    case 0x60: /* Fallthrough */
242
255k
    case 0x61: /* Fallthrough */
243
272k
    case 0x62: /* Fallthrough */
244
297k
    case 0x63: /* Fallthrough */
245
302k
    case 0x64: /* Fallthrough */
246
352k
    case 0x65: /* Fallthrough */
247
381k
    case 0x66: /* Fallthrough */
248
384k
    case 0x67: /* Fallthrough */
249
391k
    case 0x68: /* Fallthrough */
250
407k
    case 0x69: /* Fallthrough */
251
411k
    case 0x6A: /* Fallthrough */
252
413k
    case 0x6B: /* Fallthrough */
253
416k
    case 0x6C: /* Fallthrough */
254
418k
    case 0x6D: /* Fallthrough */
255
421k
    case 0x6E: /* Fallthrough */
256
422k
    case 0x6F: /* Fallthrough */
257
428k
    case 0x70: /* Fallthrough */
258
429k
    case 0x71: /* Fallthrough */
259
431k
    case 0x72: /* Fallthrough */
260
435k
    case 0x73: /* Fallthrough */
261
639k
    case 0x74: /* Fallthrough */
262
643k
    case 0x75: /* Fallthrough */
263
646k
    case 0x76: /* Fallthrough */
264
648k
    case 0x77:
265
      /* Embedded one byte length string */
266
648k
      {
267
648k
        uint64_t length = _cbor_load_uint8(source) - 0x60; /* 0x60 offset */
268
648k
        CLAIM_BYTES_AND_INVOKE(string, length, 0);
269
648k
        return result;
270
646k
      }
271
6.44k
    case 0x78:
272
      /* One byte length string */
273
6.44k
      READ_CLAIM_INVOKE(string, _cbor_load_uint8, 1);
274
4.40k
    case 0x79:
275
      /* Two bytes length string */
276
4.40k
      READ_CLAIM_INVOKE(string, _cbor_load_uint16, 2);
277
2.60k
    case 0x7A:
278
      /* Four bytes length string */
279
2.60k
      READ_CLAIM_INVOKE(string, _cbor_load_uint32, 4);
280
5.36k
    case 0x7B:
281
      /* Eight bytes length string */
282
5.36k
      READ_CLAIM_INVOKE(string, _cbor_load_uint64, 8);
283
565
    case 0x7C: /* Fallthrough */
284
980
    case 0x7D: /* Fallthrough */
285
1.46k
    case 0x7E:
286
      /* Reserved */
287
1.46k
      { return (struct cbor_decoder_result){.status = CBOR_DECODER_ERROR}; }
288
13.4k
    case 0x7F:
289
      /* Indefinite length string */
290
13.4k
      {
291
13.4k
        callbacks->string_start(context);
292
13.4k
        return result;
293
980
      }
294
15.3k
    case 0x80: /* Fallthrough */
295
25.9k
    case 0x81: /* Fallthrough */
296
56.1k
    case 0x82: /* Fallthrough */
297
67.1k
    case 0x83: /* Fallthrough */
298
72.9k
    case 0x84: /* Fallthrough */
299
86.8k
    case 0x85: /* Fallthrough */
300
114k
    case 0x86: /* Fallthrough */
301
118k
    case 0x87: /* Fallthrough */
302
122k
    case 0x88: /* Fallthrough */
303
183k
    case 0x89: /* Fallthrough */
304
198k
    case 0x8A: /* Fallthrough */
305
202k
    case 0x8B: /* Fallthrough */
306
205k
    case 0x8C: /* Fallthrough */
307
212k
    case 0x8D: /* Fallthrough */
308
217k
    case 0x8E: /* Fallthrough */
309
230k
    case 0x8F: /* Fallthrough */
310
270k
    case 0x90: /* Fallthrough */
311
272k
    case 0x91: /* Fallthrough */
312
277k
    case 0x92: /* Fallthrough */
313
287k
    case 0x93: /* Fallthrough */
314
318k
    case 0x94: /* Fallthrough */
315
340k
    case 0x95: /* Fallthrough */
316
358k
    case 0x96: /* Fallthrough */
317
371k
    case 0x97:
318
      /* Embedded one byte length array */
319
371k
      {
320
371k
        callbacks->array_start(
321
371k
            context, _cbor_load_uint8(source) - 0x80); /* 0x40 offset */
322
371k
        return result;
323
358k
      }
324
14.7k
    case 0x98:
325
      /* One byte length array */
326
14.7k
      {
327
14.7k
        if (claim_bytes(1, source_size, &result)) {
328
14.3k
          callbacks->array_start(context, _cbor_load_uint8(source + 1));
329
14.3k
        }
330
14.7k
        return result;
331
358k
      }
332
1.97k
    case 0x99:
333
      /* Two bytes length array */
334
1.97k
      {
335
1.97k
        if (claim_bytes(2, source_size, &result)) {
336
1.58k
          callbacks->array_start(context, _cbor_load_uint16(source + 1));
337
1.58k
        }
338
1.97k
        return result;
339
358k
      }
340
1.99k
    case 0x9A:
341
      /* Four bytes length array */
342
1.99k
      {
343
1.99k
        if (claim_bytes(4, source_size, &result)) {
344
1.59k
          callbacks->array_start(context, _cbor_load_uint32(source + 1));
345
1.59k
        }
346
1.99k
        return result;
347
358k
      }
348
1.59k
    case 0x9B:
349
      /* Eight bytes length array */
350
1.59k
      {
351
1.59k
        if (claim_bytes(8, source_size, &result)) {
352
1.14k
          callbacks->array_start(context, _cbor_load_uint64(source + 1));
353
1.14k
        }
354
1.59k
        return result;
355
358k
      }
356
403
    case 0x9C: /* Fallthrough */
357
807
    case 0x9D: /* Fallthrough */
358
1.20k
    case 0x9E:
359
      /* Reserved */
360
1.20k
      { return (struct cbor_decoder_result){.status = CBOR_DECODER_ERROR}; }
361
302k
    case 0x9F:
362
      /* Indefinite length array */
363
302k
      {
364
302k
        callbacks->indef_array_start(context);
365
302k
        return result;
366
807
      }
367
3.89M
    case 0xA0: /* Fallthrough */
368
4.19M
    case 0xA1: /* Fallthrough */
369
4.22M
    case 0xA2: /* Fallthrough */
370
4.23M
    case 0xA3: /* Fallthrough */
371
4.24M
    case 0xA4: /* Fallthrough */
372
4.34M
    case 0xA5: /* Fallthrough */
373
4.34M
    case 0xA6: /* Fallthrough */
374
4.36M
    case 0xA7: /* Fallthrough */
375
4.36M
    case 0xA8: /* Fallthrough */
376
4.37M
    case 0xA9: /* Fallthrough */
377
4.37M
    case 0xAA: /* Fallthrough */
378
4.38M
    case 0xAB: /* Fallthrough */
379
4.39M
    case 0xAC: /* Fallthrough */
380
4.41M
    case 0xAD: /* Fallthrough */
381
4.42M
    case 0xAE: /* Fallthrough */
382
4.43M
    case 0xAF: /* Fallthrough */
383
4.43M
    case 0xB0: /* Fallthrough */
384
4.44M
    case 0xB1: /* Fallthrough */
385
4.44M
    case 0xB2: /* Fallthrough */
386
4.46M
    case 0xB3: /* Fallthrough */
387
4.47M
    case 0xB4: /* Fallthrough */
388
4.47M
    case 0xB5: /* Fallthrough */
389
4.48M
    case 0xB6: /* Fallthrough */
390
4.50M
    case 0xB7:
391
      /* Embedded one byte length map */
392
4.50M
      {
393
4.50M
        callbacks->map_start(context,
394
4.50M
                             _cbor_load_uint8(source) - 0xA0); /* 0xA0 offset */
395
4.50M
        return result;
396
4.48M
      }
397
10.1k
    case 0xB8:
398
      /* One byte length map */
399
10.1k
      {
400
10.1k
        if (claim_bytes(1, source_size, &result)) {
401
9.68k
          callbacks->map_start(context, _cbor_load_uint8(source + 1));
402
9.68k
        }
403
10.1k
        return result;
404
4.48M
      }
405
9.48k
    case 0xB9:
406
      /* Two bytes length map */
407
9.48k
      {
408
9.48k
        if (claim_bytes(2, source_size, &result)) {
409
9.09k
          callbacks->map_start(context, _cbor_load_uint16(source + 1));
410
9.09k
        }
411
9.48k
        return result;
412
4.48M
      }
413
1.71k
    case 0xBA:
414
      /* Four bytes length map */
415
1.71k
      {
416
1.71k
        if (claim_bytes(4, source_size, &result)) {
417
1.31k
          callbacks->map_start(context, _cbor_load_uint32(source + 1));
418
1.31k
        }
419
1.71k
        return result;
420
4.48M
      }
421
1.61k
    case 0xBB:
422
      /* Eight bytes length map */
423
1.61k
      {
424
1.61k
        if (claim_bytes(8, source_size, &result)) {
425
1.21k
          callbacks->map_start(context, _cbor_load_uint64(source + 1));
426
1.21k
        }
427
1.61k
        return result;
428
4.48M
      }
429
523
    case 0xBC: /* Fallthrough */
430
953
    case 0xBD: /* Fallthrough */
431
1.35k
    case 0xBE:
432
      /* Reserved */
433
1.35k
      { return (struct cbor_decoder_result){.status = CBOR_DECODER_ERROR}; }
434
183k
    case 0xBF:
435
      /* Indefinite length map */
436
183k
      {
437
183k
        callbacks->indef_map_start(context);
438
183k
        return result;
439
953
      }
440
      /* See https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml for tag
441
       * assignment. All well-formed tags are processed regardless of validity
442
       * since maintaining the known mapping would be impractical.
443
       *
444
       * Moreover, even tags in the reserved "standard" range are not assigned
445
       * but may get assigned in the future (see e.g.
446
       * https://github.com/PJK/libcbor/issues/307), so processing all tags
447
       * improves forward compatibility.
448
       */
449
4.97k
    case 0xC0: /* Fallthrough */
450
34.3k
    case 0xC1: /* Fallthrough */
451
50.3k
    case 0xC2: /* Fallthrough */
452
52.7k
    case 0xC3: /* Fallthrough */
453
70.6k
    case 0xC4: /* Fallthrough */
454
104k
    case 0xC5: /* Fallthrough */
455
113k
    case 0xC6: /* Fallthrough */
456
127k
    case 0xC7: /* Fallthrough */
457
146k
    case 0xC8: /* Fallthrough */
458
230k
    case 0xC9: /* Fallthrough */
459
249k
    case 0xCA: /* Fallthrough */
460
314k
    case 0xCB: /* Fallthrough */
461
319k
    case 0xCC: /* Fallthrough */
462
368k
    case 0xCD: /* Fallthrough */
463
399k
    case 0xCE: /* Fallthrough */
464
421k
    case 0xCF: /* Fallthrough */
465
614k
    case 0xD0: /* Fallthrough */
466
622k
    case 0xD1: /* Fallthrough */
467
637k
    case 0xD2: /* Fallthrough */
468
660k
    case 0xD3: /* Fallthrough */
469
663k
    case 0xD4: /* Fallthrough */
470
679k
    case 0xD5: /* Fallthrough */
471
691k
    case 0xD6: /* Fallthrough */
472
713k
    case 0xD7: /* Fallthrough */
473
713k
    {
474
713k
      callbacks->tag(context, (uint64_t)(_cbor_load_uint8(source) -
475
713k
                                         0xC0)); /* 0xC0 offset */
476
713k
      return result;
477
691k
    }
478
29.0k
    case 0xD8: /* 1B tag */
479
29.0k
    {
480
29.0k
      if (claim_bytes(1, source_size, &result)) {
481
28.6k
        callbacks->tag(context, _cbor_load_uint8(source + 1));
482
28.6k
      }
483
29.0k
      return result;
484
691k
    }
485
6.06k
    case 0xD9: /* 2B tag */
486
6.06k
    {
487
6.06k
      if (claim_bytes(2, source_size, &result)) {
488
5.64k
        callbacks->tag(context, _cbor_load_uint16(source + 1));
489
5.64k
      }
490
6.06k
      return result;
491
691k
    }
492
5.61k
    case 0xDA: /* 4B tag */
493
5.61k
    {
494
5.61k
      if (claim_bytes(4, source_size, &result)) {
495
5.21k
        callbacks->tag(context, _cbor_load_uint32(source + 1));
496
5.21k
      }
497
5.61k
      return result;
498
691k
    }
499
2.69k
    case 0xDB: /* 8B tag */
500
2.69k
    {
501
2.69k
      if (claim_bytes(8, source_size, &result)) {
502
2.29k
        callbacks->tag(context, _cbor_load_uint64(source + 1));
503
2.29k
      }
504
2.69k
      return result;
505
691k
    }
506
405
    case 0xDC: /* Fallthrough */
507
815
    case 0xDD: /* Fallthrough */
508
1.21k
    case 0xDE: /* Fallthrough */
509
1.81k
    case 0xDF: /* Reserved */
510
1.81k
    {
511
1.81k
      return (struct cbor_decoder_result){.status = CBOR_DECODER_ERROR};
512
1.21k
    }
513
411
    case 0xE0: /* Fallthrough */
514
849
    case 0xE1: /* Fallthrough */
515
1.28k
    case 0xE2: /* Fallthrough */
516
1.68k
    case 0xE3: /* Fallthrough */
517
2.10k
    case 0xE4: /* Fallthrough */
518
2.53k
    case 0xE5: /* Fallthrough */
519
3.10k
    case 0xE6: /* Fallthrough */
520
3.50k
    case 0xE7: /* Fallthrough */
521
3.92k
    case 0xE8: /* Fallthrough */
522
4.38k
    case 0xE9: /* Fallthrough */
523
4.79k
    case 0xEA: /* Fallthrough */
524
5.19k
    case 0xEB: /* Fallthrough */
525
5.60k
    case 0xEC: /* Fallthrough */
526
6.05k
    case 0xED: /* Fallthrough */
527
7.03k
    case 0xEE: /* Fallthrough */
528
7.45k
    case 0xEF: /* Fallthrough */
529
7.94k
    case 0xF0: /* Fallthrough */
530
8.34k
    case 0xF1: /* Fallthrough */
531
8.74k
    case 0xF2: /* Fallthrough */
532
9.31k
    case 0xF3: /* Simple value - unassigned */
533
9.31k
    {
534
9.31k
      return (struct cbor_decoder_result){.status = CBOR_DECODER_ERROR};
535
8.74k
    }
536
12.2k
    case 0xF4:
537
      /* False */
538
12.2k
      {
539
12.2k
        callbacks->boolean(context, false);
540
12.2k
        return result;
541
8.74k
      }
542
22.3k
    case 0xF5:
543
      /* True */
544
22.3k
      {
545
22.3k
        callbacks->boolean(context, true);
546
22.3k
        return result;
547
8.74k
      }
548
3.89k
    case 0xF6:
549
      /* Null */
550
3.89k
      {
551
3.89k
        callbacks->null(context);
552
3.89k
        return result;
553
8.74k
      }
554
136k
    case 0xF7:
555
      /* Undefined */
556
136k
      {
557
136k
        callbacks->undefined(context);
558
136k
        return result;
559
8.74k
      }
560
432
    case 0xF8:
561
      /* 1B simple value, unassigned */
562
432
      { return (struct cbor_decoder_result){.status = CBOR_DECODER_ERROR}; }
563
21.4k
    case 0xF9:
564
      /* 2B float */
565
21.4k
      {
566
21.4k
        if (claim_bytes(2, source_size, &result)) {
567
20.9k
          callbacks->float2(context, _cbor_load_half(source + 1));
568
20.9k
        }
569
21.4k
        return result;
570
8.74k
      }
571
8.85k
    case 0xFA:
572
      /* 4B float */
573
8.85k
      {
574
8.85k
        if (claim_bytes(4, source_size, &result)) {
575
8.32k
          callbacks->float4(context, _cbor_load_float(source + 1));
576
8.32k
        }
577
8.85k
        return result;
578
8.74k
      }
579
4.01k
    case 0xFB:
580
      /* 8B float */
581
4.01k
      {
582
4.01k
        if (claim_bytes(8, source_size, &result)) {
583
3.55k
          callbacks->float8(context, _cbor_load_double(source + 1));
584
3.55k
        }
585
4.01k
        return result;
586
8.74k
      }
587
546
    case 0xFC: /* Fallthrough */
588
989
    case 0xFD: /* Fallthrough */
589
1.46k
    case 0xFE:
590
      /* Reserved */
591
1.46k
      { return (struct cbor_decoder_result){.status = CBOR_DECODER_ERROR}; }
592
215k
    case 0xFF:
593
      /* Break */
594
215k
      callbacks->indef_break(context);
595
      // Never happens, the switch statement is exhaustive on the 1B range; make
596
      // compiler happy
597
215k
    default:
598
215k
      return result;
599
13.1M
  }
600
13.1M
}