Systemd/src/fuzz/fuzz-main.c
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00

43 lines
1.2 KiB
C

/* SPDX-License-Identifier: LGPL-2.1+ */
/***
Copyright 2018 Jonathan Rudenberg
***/
#include "alloc-util.h"
#include "log.h"
#include "fileio.h"
#include "fuzz.h"
/* This is a test driver for the systemd fuzzers that provides main function
* for regression testing outside of oss-fuzz (https://github.com/google/oss-fuzz)
*
* It reads files named on the command line and passes them one by one into the
* fuzzer that it is compiled into. */
int main(int argc, char **argv) {
int i, r;
size_t size;
char *name;
log_set_max_level(LOG_DEBUG);
log_parse_environment();
log_open();
for (i = 1; i < argc; i++) {
_cleanup_free_ char *buf = NULL;
name = argv[i];
r = read_full_file(name, &buf, &size);
if (r < 0) {
log_error_errno(r, "Failed to open '%s': %m", name);
return EXIT_FAILURE;
}
printf("%s... ", name);
fflush(stdout);
(void) LLVMFuzzerTestOneInput((uint8_t*)buf, size);
printf("ok\n");
}
return EXIT_SUCCESS;
}