Debian Codegraph @

fuzz/fuzz_properties_decode.c

raw symbols SCIP
1 // Copyright 2007 - 2026, Arthur Chan and the rabbitmq-c contributors.
2 // SPDX-License-Identifier: mit
3
4 #include <errno.h>
5 #include <inttypes.h>
6 #include <math.h>
7 #include <stdarg.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11
12 #include <rabbitmq-c/amqp.h>
13 #include <rabbitmq-c/framing.h>
14
15 // Drives amqp_decode_properties(), the generated decoder for every AMQP
16 // content-header (properties) frame. The first 2 bytes are the class id
17 // (big-endian), the rest the body.
18 extern int LLVMFuzzerTestOneInput(const char *data, size_t size) {
19
20 int unused_result;
21 amqp_pool_t pool;
22 uint16_t class_id;
23
24 if (size < 2) {
25 return 0;
26 }
27
28 class_id = ((uint16_t)(uint8_t)data[0] << 8) |
29 ((uint16_t)(uint8_t)data[1]);
30
31 init_amqp_pool(&pool, 4096);
32 {
33 void *decoded = NULL;
34 amqp_bytes_t encoded;
35 encoded.len = size - 2;
36 encoded.bytes = (void *)(data + 2);
37
38 unused_result = amqp_decode_properties(class_id, &pool, encoded, &decoded);
39 }
40 empty_amqp_pool(&pool);
41 return 0;
42 }