add fuzz_string_length

This commit is contained in:
disconnect3d 2023-12-01 19:03:27 +01:00
parent ee352110f5
commit 275fb8997f
4 changed files with 25 additions and 4 deletions

View file

@ -405,7 +405,7 @@ executable(
# Note: this target must be built with clang! # Note: this target must be built with clang!
executable( executable(
'fuzz_wordsplit', 'fuzz_wordsplit',
fuzzing_sources, fuzz_wordsplit_sources,
include_directories : includes, include_directories : includes,
link_with : [libcommon], link_with : [libcommon],
dependencies : [], dependencies : [],
@ -413,6 +413,18 @@ executable(
link_args : ['-fsanitize=fuzzer,address', '-ggdb', '-O0', '-fno-omit-frame-pointer'], link_args : ['-fsanitize=fuzzer,address', '-ggdb', '-O0', '-fno-omit-frame-pointer'],
) )
# Note: this target must be built with clang!
executable(
'fuzz_string_length',
[fuzz_string_length_sources, pacman_sources],
include_directories : includes,
link_with : [libalpm_a, libcommon],
dependencies : [],
c_args : ['-fsanitize=fuzzer,address', '-ggdb', '-O0', '-fno-omit-frame-pointer', '-DFUZZING_PACMAN'],
link_args : ['-fsanitize=fuzzer,address', '-ggdb', '-O0', '-fno-omit-frame-pointer'],
)
foreach wrapper : script_wrappers foreach wrapper : script_wrappers
cdata = configuration_data() cdata = configuration_data()
cdata.set_quoted('BASH', BASH.full_path()) cdata.set_quoted('BASH', BASH.full_path())

View file

@ -5,11 +5,14 @@
#include <string.h> #include <string.h>
#include <wchar.h> #include <wchar.h>
#include "util.h" // TODO/FIXME: Fix the util.h include
//#include "util.h"
// And remove that function header from here
size_t string_length(const char *s);
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size); int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
static int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
if (Size == 0) if (Size == 0)
return 0; return 0;

View file

@ -1,3 +1,7 @@
fuzzing_sources = files(''' fuzz_wordsplit_sources = files('''
fuzz_wordsplit.c fuzz_wordsplit.c
'''.split()) '''.split())
fuzz_string_length_sources = files('''
fuzz_string_length.c
'''.split())

View file

@ -1079,6 +1079,7 @@ static void cl_to_log(int argc, char *argv[])
} }
} }
#ifndef FUZZING_PACMAN
/** Main function. /** Main function.
* @param argc * @param argc
* @param argv * @param argv
@ -1273,3 +1274,4 @@ int main(int argc, char *argv[])
/* not reached */ /* not reached */
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
#endif //FUZZING_PACMAN