-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1233 from securitykernel/libfuzzer-setup
Add libFuzzer setup
- Loading branch information
Showing
8 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <stdio.h> | ||
#include <locale.h> | ||
#include <glib.h> | ||
#include <glib/gstdio.h> | ||
|
||
#include <config_file.h> | ||
#include <context.h> | ||
#include <bundle.h> | ||
|
||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) | ||
{ | ||
g_autofree gchar *tmpdir = NULL; | ||
g_autofree gchar *bundlename = NULL; | ||
g_autoptr(RaucBundle) bundle = NULL; | ||
g_autoptr(GError) error = NULL; | ||
|
||
tmpdir = g_dir_make_tmp("rauc-XXXXXX", NULL); | ||
g_assert_nonnull(tmpdir); | ||
|
||
r_context_conf()->certpath = g_strdup("test/openssl-ca/dev/autobuilder-1.cert.pem"); | ||
r_context_conf()->keypath = g_strdup("test/openssl-ca/dev/private/autobuilder-1.pem"); | ||
r_context(); | ||
|
||
bundlename = g_build_filename(tmpdir, "fuzz-bundle.raucb", NULL); | ||
g_assert_nonnull(bundlename); | ||
g_file_set_contents(bundlename, (gchar*)data, size, &error); | ||
|
||
(void) check_bundle(bundlename, &bundle, CHECK_BUNDLE_NO_VERIFY, NULL, &error); | ||
|
||
g_free(r_context()->certpath); | ||
g_free(r_context()->keypath); | ||
g_remove(bundlename); | ||
g_remove(tmpdir); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <stdio.h> | ||
#include <locale.h> | ||
#include <glib.h> | ||
#include <glib/gstdio.h> | ||
|
||
#include <config_file.h> | ||
#include <context.h> | ||
#include <manifest.h> | ||
|
||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) | ||
{ | ||
g_autoptr(GBytes) dt = g_bytes_new(data, size); | ||
g_autoptr(RaucManifest) rm = NULL; | ||
g_autoptr(GError) error = NULL; | ||
|
||
(void) load_manifest_mem(dt, &rm, &error); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"[update]" | ||
"compatible=" | ||
"version=" | ||
"description=" | ||
"build=" | ||
|
||
"[bundle]" | ||
"format=" | ||
"plain" | ||
"verity" | ||
"crypt" | ||
"verity=" | ||
"verity-hash=" | ||
"verity-salt=" | ||
"verity-size=" | ||
|
||
"[hooks]" | ||
"hooks=" | ||
"install-check" | ||
|
||
"[handler]" | ||
"args=" | ||
|
||
"[image.rootfs]" | ||
"filename=" | ||
"rootfs.ext4" | ||
"size=" | ||
"sha256=" | ||
"hooks=" | ||
"pre-" | ||
"post-" | ||
"install" | ||
"adaptive=" | ||
"block-hash-index" | ||
|
||
"[image.appfs]" | ||
"filename" | ||
"appfs.ext4" | ||
"size" | ||
"sha256" | ||
|
||
"[meta.foo]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
if not get_option('fuzzing') | ||
subdir_done() | ||
endif | ||
|
||
fuzzers = [ | ||
'manifest', | ||
'bundle', | ||
] | ||
|
||
fuzzer_c_args = cc.get_supported_arguments('-Wno-missing-prototypes') | ||
|
||
foreach fuzzer_name : fuzzers | ||
exe = executable( | ||
fuzzer_name + '_fuzzer', | ||
fuzzer_name + '.c', | ||
extra_test_sources, | ||
c_args : ['-fsanitize=fuzzer,address'] + fuzzer_c_args, | ||
link_args : ['-fsanitize=fuzzer,address'], | ||
link_with : librauc, | ||
include_directories : incdir, | ||
dependencies : rauc_deps) | ||
endforeach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters