Coverage Report

Created: 2026-06-10 06:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/strongswan/fuzz/fuzz_vici.c
Line
Count
Source
1
/*
2
 * Copyright (C) 2026 Arthur SC Chan
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 <daemon.h>
18
#include <library.h>
19
#include <plugins/vici/vici_message.h>
20
21
int LLVMFuzzerInitialize(int *argc, char ***argv)
22
4
{
23
4
  dbg_default_set_level(-1);
24
4
  library_init(NULL, "fuzz_vici");
25
4
  libcharon_init();
26
4
  return 0;
27
4
}
28
29
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
30
644
{
31
644
  enumerator_t *enumerator;
32
644
  vici_message_t *msg;
33
644
  chunk_t data, value;
34
644
  vici_type_t type;
35
644
  char *name;
36
644
  int count;
37
38
644
  if (len < 1)
39
0
  {
40
0
    return 0;
41
0
  }
42
43
644
  data = chunk_create((u_char*)buf, len);
44
644
  msg = vici_message_create_from_data(data, FALSE);
45
46
644
  msg->get_str(msg, NULL, "version");
47
644
  msg->get_int(msg, 0, "timeout");
48
644
  msg->get_bool(msg, FALSE, "enabled");
49
644
  msg->get_value(msg, chunk_empty, "data");
50
51
644
  enumerator = msg->create_enumerator(msg);
52
644
  count = 0;
53
3.39M
  while (count++ < 10000 &&
54
3.39M
       enumerator->enumerate(enumerator, &type, &name, &value));
55
644
  enumerator->destroy(enumerator);
56
57
644
  msg->destroy(msg);
58
644
  return 0;
59
644
}