tests: add a fuzzer for dev_kmsg_record

This commit is contained in:
Evgeny Vereshchagin
2018-11-16 08:44:35 +01:00
parent a6da77b71b
commit 8857fb9beb
8 changed files with 44 additions and 1 deletions
+29
View File
@@ -0,0 +1,29 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include "fuzz.h"
#include "journald-kmsg.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
Server s = {};
_cleanup_free_ char *buffer = NULL;
if (size == 0)
return 0;
s = (Server) {
.native_fd = -1,
.stdout_fd = -1,
.dev_kmsg_fd = -1,
.audit_fd = -1,
.hostname_fd = -1,
.notify_fd = -1,
.storage = STORAGE_NONE,
};
assert_se(sd_event_default(&s.event) >= 0);
buffer = memdup(data, size);
assert_se(buffer);
dev_kmsg_record(&s, buffer, size);
server_done(&s);
return 0;
}
+5
View File
@@ -51,6 +51,11 @@ fuzzers += [
libshared],
[libmount]],
[['src/fuzz/fuzz-journald-kmsg.c'],
[libjournal_core,
libshared],
[libselinux]],
[['src/fuzz/fuzz-journald-native.c',
'src/fuzz/fuzz-journald.c'],
[libjournal_core,