/src/librabbitmq/fuzz/fuzz_url.c
Line | Count | Source |
1 | | // Copyright 2007 - 2022, Alan Antonuk and the rabbitmq-c contributors. |
2 | | // SPDX-License-Identifier: mit |
3 | | |
4 | | #include <inttypes.h> |
5 | | #include <stddef.h> |
6 | | #include <stdint.h> |
7 | | #include <stdlib.h> |
8 | | #include <string.h> |
9 | | |
10 | | #include <rabbitmq-c/amqp.h> |
11 | | |
12 | 1.46k | extern int LLVMFuzzerTestOneInput(const char *data, size_t size) { |
13 | | // amqp_parse_url expects null-terminated string that it can modify, |
14 | | // LLVMFuzzer expects that data will not be modified and won't necessarily |
15 | | // null terminate the string, so do that here. |
16 | 1.46k | char* in = malloc(size + 1); |
17 | 1.46k | memcpy(in, data, size); |
18 | 1.46k | in[size] = '\0'; |
19 | | |
20 | 1.46k | struct amqp_connection_info ci; |
21 | 1.46k | amqp_parse_url(in, &ci); |
22 | 1.46k | free(in); |
23 | 1.46k | return 0; |
24 | 1.46k | } |