Coverage Report

Created: 2026-07-16 06:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/strongswan/fuzz/fuzz_ids.c
Line
Count
Source
1
/*
2
 * Copyright (C) 2018 Tobias Brunner
3
 *
4
 * Copyright (C) secunet Security Networks AG
5
 *
6
 * This program is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License as published by the
8
 * Free Software Foundation; either version 2 of the License, or (at your
9
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
10
 *
11
 * This program is distributed in the hope that it will be useful, but
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
 * for more details.
15
 */
16
17
#include <library.h>
18
#include <utils/debug.h>
19
20
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
21
2.36k
{
22
2.36k
  identification_t *id, *clone;
23
2.36k
  enumerator_t *part_enum;
24
2.36k
  chunk_t chunk, data;
25
2.36k
  id_part_t part;
26
2.36k
  char str_buf[BUF_LEN], min_buf[3];
27
28
2.36k
  dbg_default_set_level(-1);
29
2.36k
  library_init(NULL, "fuzz_ids");
30
31
2.36k
  chunk = chunk_create((u_char*)buf, len);
32
2.36k
  id = identification_create_from_data(chunk);
33
2.36k
  if (id)
34
2.36k
  {
35
2.36k
    id->hash(id, 0U);
36
2.36k
    id->equals(id, id);
37
2.36k
    id->matches(id, id);
38
2.36k
    id->contains_wildcards(id);
39
40
2.36k
    part_enum = id->create_part_enumerator(id);
41
2.36k
    if (part_enum)
42
2.36k
    {
43
6.72k
      while (part_enum->enumerate(part_enum, &part, &data));
44
2.36k
      part_enum->destroy(part_enum);
45
2.36k
    }
46
47
2.36k
    clone = id->clone(id);
48
2.36k
    clone->destroy(clone);
49
2.36k
  }
50
51
2.36k
  snprintf(str_buf, sizeof(str_buf), "%Y", id);
52
2.36k
  snprintf(min_buf, sizeof(min_buf), "%Y", id);
53
2.36k
  DESTROY_IF(id);
54
55
2.36k
  library_deinit();
56
2.36k
  return 0;
57
2.36k
}