Coverage Report

Created: 2026-06-30 06:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/lxc/src/tests/fuzz-lxc-config-read.c
Line
Count
Source
1
/*
2
 * SPDX-License-Identifier: LGPL-2.1+
3
 */
4
5
#include "config.h"
6
7
#include <stddef.h>
8
#include <stdint.h>
9
10
#include "conf.h"
11
#include "confile.h"
12
#include "lxctest.h"
13
#include "utils.h"
14
15
11.0k
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
16
11.0k
  int fd = -1;
17
11.0k
  char tmpf[] = "/tmp/fuzz-lxc-config-read-XXXXXX";
18
11.0k
  struct lxc_conf *conf = NULL;
19
20
  /*
21
   * 100Kb should probably be enough to trigger all the issues
22
   * we're interested in without any timeouts
23
   */
24
11.0k
  if (size > 102400)
25
4
    return 0;
26
27
11.0k
  fd = lxc_make_tmpfile(tmpf, false);
28
11.0k
  lxc_test_assert_abort(fd >= 0);
29
11.0k
  lxc_write_nointr(fd, data, size);
30
11.0k
  close(fd);
31
32
11.0k
  conf = lxc_conf_init();
33
11.0k
  lxc_test_assert_abort(conf);
34
11.0k
  lxc_config_read(tmpf, conf, false);
35
11.0k
  lxc_conf_free(conf);
36
37
11.0k
  (void) unlink(tmpf);
38
11.0k
  return 0;
39
11.0k
}