Coverage Report

Created: 2025-12-31 07:02

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/glib/fuzzing/fuzz_dbus_message.c
Line
Count
Source
1
/*
2
 * Copyright 2018 pdknsk
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18
 */
19
20
#include "fuzz.h"
21
22
static const GDBusCapabilityFlags flags = G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING;
23
24
int
25
LLVMFuzzerTestOneInput (const unsigned char *data, size_t size)
26
3.38k
{
27
3.38k
  gssize bytes;
28
3.38k
  GDBusMessage *msg = NULL;
29
3.38k
  guchar *blob = NULL;
30
3.38k
  gsize msg_size;
31
32
3.38k
  fuzz_set_logging_func ();
33
34
3.38k
  bytes = g_dbus_message_bytes_needed ((guchar*) data, size, NULL);
35
3.38k
  if (bytes <= 0)
36
31
    return 0;
37
38
3.35k
  msg = g_dbus_message_new_from_blob ((guchar*) data, size, flags, NULL);
39
3.35k
  if (msg == NULL)
40
2.00k
    return 0;
41
42
1.35k
  blob = g_dbus_message_to_blob (msg, &msg_size, flags, NULL);
43
44
1.35k
  g_free (blob);
45
1.35k
  g_object_unref (msg);
46
1.35k
  return 0;
47
3.35k
}