]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/fuzz/fuzz-main.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 Copyright 2018 Jonathan Rudenberg
5 systemd is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 systemd is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with systemd; If not, see <http://www.gnu.org/licenses/>.
19 #include "alloc-util.h"
24 /* This is a test driver for the systemd fuzzers that provides main function
25 * for regression testing outside of oss-fuzz (https://github.com/google/oss-fuzz)
27 * It reads files named on the command line and passes them one by one into the
28 * fuzzer that it is compiled into. */
30 int main(int argc
, char **argv
) {
35 log_set_max_level(LOG_DEBUG
);
36 log_parse_environment();
39 for (i
= 1; i
< argc
; i
++) {
40 _cleanup_free_
char *buf
= NULL
;
43 r
= read_full_file(name
, &buf
, &size
);
45 log_error_errno(r
, "Failed to open '%s': %m", name
);
48 printf("%s... ", name
);
50 (void) LLVMFuzzerTestOneInput((uint8_t*)buf
, size
);