Coverage Report

Created: 2025-12-08 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/glib/fuzzing/fuzz_special_dirs.c
Line
Count
Source
1
/*
2
 * Copyright 2025 Philip Withnall
3
 * Copyright 2025 Tobias Stoeckmann
4
 *
5
 * SPDX-License-Identifier: LGPL-2.1-or-later
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#include "fuzz.h"
22
#include "glib.h"
23
#include "gutilsprivate.c"
24
25
int
26
LLVMFuzzerTestOneInput (const unsigned char *data, size_t size)
27
1.34k
{
28
1.34k
  gchar *special_dirs[G_USER_N_DIRECTORIES] = { 0 };
29
1.34k
  unsigned char *nul_terminated_data = NULL;
30
31
1.34k
  fuzz_set_logging_func ();
32
33
1.34k
  nul_terminated_data = (unsigned char *) g_strndup ((const char *) data, size);
34
35
1.34k
  load_user_special_dirs_from_string ((const gchar *) nul_terminated_data, "/dev/null", special_dirs);
36
37
  /* Test directories and make sure that, if they exist, they are absolute. */
38
12.1k
  for (GUserDirectory dir_type = G_USER_DIRECTORY_DESKTOP; dir_type < G_USER_N_DIRECTORIES; dir_type++)
39
10.7k
    {
40
10.7k
      char *dir = special_dirs[dir_type];
41
10.7k
      g_assert_true (dir == NULL || g_path_is_absolute (dir));
42
10.7k
      g_free (dir);
43
10.7k
    }
44
45
1.34k
  g_free (nul_terminated_data);
46
47
1.34k
  return 0;
48
1.34k
}