From 55944e5e40b1be2afc4855d8d2baf4b73d1876b5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 22:49:52 +0200 Subject: Adding upstream version 255.4. Signed-off-by: Daniel Baumann --- src/fuzz/fuzz-varlink-idl.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/fuzz/fuzz-varlink-idl.c (limited to 'src/fuzz/fuzz-varlink-idl.c') diff --git a/src/fuzz/fuzz-varlink-idl.c b/src/fuzz/fuzz-varlink-idl.c new file mode 100644 index 0000000..2436342 --- /dev/null +++ b/src/fuzz/fuzz-varlink-idl.c @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include + +#include "errno-util.h" +#include "fd-util.h" +#include "fuzz.h" +#include "io-util.h" +#include "varlink-idl.h" +#include "log.h" + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + _cleanup_(varlink_interface_freep) VarlinkInterface *vi = NULL; + _cleanup_free_ char *str = NULL, *dump = NULL; + int r; + + if (outside_size_range(size, 0, 64 * 1024)) + return 0; + + fuzz_setup_logging(); + + assert_se(str = memdup_suffix0(data, size)); + + r = varlink_idl_parse(str, /* line= */ NULL, /* column= */ NULL, &vi); + if (r < 0) { + log_debug_errno(r, "Failed to parse varlink interface definition: %m"); + return 0; + } + + assert_se(varlink_idl_format(vi, &dump) >= 0); + (void) varlink_idl_consistent(vi, LOG_DEBUG); + + return 0; +} -- cgit v1.2.3