| 1 |
|
| 2 |
|
| 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 |
|
| 16 |
|
| 17 |
extern int LLVMFuzzerTestOneInput(const char *data, size_t size) { |
| 18 |
|
| 19 |
int unused_result; |
| 20 |
amqp_pool_t pool; |
| 21 |
amqp_method_number_t method_id; |
| 22 |
|
| 23 |
if (size < 4) { |
| 24 |
return 0; |
| 25 |
} |
| 26 |
|
| 27 |
method_id = ((amqp_method_number_t)(uint8_t)data[0] << 24) | |
| 28 |
((amqp_method_number_t)(uint8_t)data[1] << 16) | |
| 29 |
((amqp_method_number_t)(uint8_t)data[2] << 8) | |
| 30 |
((amqp_method_number_t)(uint8_t)data[3]); |
| 31 |
|
| 32 |
init_amqp_pool(&pool, 4096); |
| 33 |
{ |
| 34 |
void *decoded = NULL; |
| 35 |
amqp_bytes_t encoded; |
| 36 |
encoded.len = size - 4; |
| 37 |
encoded.bytes = (void *)(data + 4); |
| 38 |
|
| 39 |
unused_result = amqp_decode_method(method_id, &pool, encoded, &decoded); |
| 40 |
} |
| 41 |
empty_amqp_pool(&pool); |
| 42 |
return 0; |
| 43 |
} |