Coverage Report

Created: 2025-08-29 06:32

/src/rauc/fuzz/bundle.c
Line
Count
Source
1
#include <stdio.h>
2
#include <locale.h>
3
#include <glib.h>
4
#include <glib/gstdio.h>
5
6
#include <config_file.h>
7
#include <context.h>
8
#include <bundle.h>
9
10
#include "fuzz.h"
11
12
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
13
5.08k
{
14
5.08k
  g_autofree gchar *tmpdir = NULL;
15
5.08k
  g_autofree gchar *bundlename = NULL;
16
5.08k
  g_autoptr(RaucBundle) bundle = NULL;
17
5.08k
  g_autoptr(GError) error = NULL;
18
19
5.08k
  fuzz_set_logging_func();
20
21
5.08k
  tmpdir = g_dir_make_tmp("rauc-XXXXXX", NULL);
22
5.08k
  g_assert_nonnull(tmpdir);
23
24
5.08k
  r_context_conf()->certpath = g_strdup("test/openssl-ca/dev/autobuilder-1.cert.pem");
25
5.08k
  r_context_conf()->keypath = g_strdup("test/openssl-ca/dev/private/autobuilder-1.pem");
26
5.08k
  r_context();
27
28
5.08k
  bundlename = g_build_filename(tmpdir, "fuzz-bundle.raucb", NULL);
29
5.08k
  g_assert_nonnull(bundlename);
30
5.08k
  g_file_set_contents(bundlename, (gchar*)data, size, &error);
31
32
5.08k
  (void) check_bundle(bundlename, &bundle, CHECK_BUNDLE_NO_VERIFY, NULL, &error);
33
34
5.08k
  g_free(r_context()->certpath);
35
5.08k
  g_free(r_context()->keypath);
36
5.08k
  g_remove(bundlename);
37
5.08k
  g_remove(tmpdir);
38
39
5.08k
  return 0;
40
5.08k
}