Coverage Report

Created: 2025-08-31 07:02

/src/fuzz_dhcp.c
Line
Count
Source
1
/* Copyright 2021 Google LLC
2
Licensed under the Apache License, Version 2.0 (the "License");
3
you may not use this file except in compliance with the License.
4
You may obtain a copy of the License at
5
      http://www.apache.org/licenses/LICENSE-2.0
6
Unless required by applicable law or agreed to in writing, software
7
distributed under the License is distributed on an "AS IS" BASIS,
8
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
See the License for the specific language governing permissions and
10
limitations under the License.
11
*/
12
13
#include "config.h"
14
#include "syshead.h"
15
#include "dhcp.h"
16
#include "buffer.h"
17
18
#include "fuzz_randomizer.h"
19
20
259
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
21
259
  struct buffer ipbuf;
22
259
  in_addr_t ret;
23
24
259
  fuzz_random_init(data, size);
25
259
  char *ran_val = get_random_string();
26
27
259
  ipbuf = alloc_buf(strlen(ran_val));
28
259
  if (buf_write(&ipbuf, ran_val, strlen(ran_val)) != false) {
29
259
    ret = dhcp_extract_router_msg(&ipbuf);
30
259
  }
31
259
  free_buf(&ipbuf);
32
33
259
  fuzz_random_destroy();
34
259
  free(ran_val);
35
36
259
  return 0;
37
259
}