summaryrefslogtreecommitdiff
path: root/fuzz/fuzz_url.c
blob: 250a3a43ad67e6ce6f3945cd71f8cbe7e7283374 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2007 - 2022, Alan Antonuk and the rabbitmq-c contributors.
// SPDX-License-Identifier: mit

#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include <rabbitmq-c/amqp.h>

extern int LLVMFuzzerTestOneInput(const char *data, size_t size) {
  // amqp_parse_url expects null-terminated string that it can modify,
  // LLVMFuzzer expects that data will not be modified and won't necessarily
  // null terminate the string, so do that here.
  char* in = malloc(size + 1);
  memcpy(in, data, size);
  in[size] = '\0';

  struct amqp_connection_info ci;
  amqp_parse_url(in, &ci);
  free(in);
  return 0;
}