/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  | 409  | 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  | 409  |   char* in = malloc(size + 1);  | 
17  | 409  |   memcpy(in, data, size);  | 
18  | 409  |   in[size] = '\0';  | 
19  |  |  | 
20  | 409  |   struct amqp_connection_info ci;  | 
21  | 409  |   amqp_parse_url(in, &ci);  | 
22  | 409  |   free(in);  | 
23  | 409  |   return 0;  | 
24  | 409  | }  |