mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
tests: put fuzz_journald_processing_function in a .c file
This commit is contained in:
parent
c155a05549
commit
231dca5579
30
src/fuzz/fuzz-journald.c
Normal file
30
src/fuzz/fuzz-journald.c
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
|
#include "alloc-util.h"
|
||||||
|
#include "fuzz-journald.h"
|
||||||
|
#include "journald-server.h"
|
||||||
|
#include "sd-event.h"
|
||||||
|
|
||||||
|
void fuzz_journald_processing_function(
|
||||||
|
const uint8_t *data,
|
||||||
|
size_t size,
|
||||||
|
void (*f)(Server *s, const char *buf, size_t raw_len, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len)
|
||||||
|
) {
|
||||||
|
Server s = {};
|
||||||
|
char *label = NULL;
|
||||||
|
size_t label_len = 0;
|
||||||
|
struct ucred *ucred = NULL;
|
||||||
|
struct timeval *tv = NULL;
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
assert_se(sd_event_default(&s.event) >= 0);
|
||||||
|
s.syslog_fd = s.native_fd = s.stdout_fd = s.dev_kmsg_fd = s.audit_fd = s.hostname_fd = s.notify_fd = -1;
|
||||||
|
s.buffer = memdup_suffix0(data, size);
|
||||||
|
assert_se(s.buffer);
|
||||||
|
s.buffer_size = size + 1;
|
||||||
|
s.storage = STORAGE_NONE;
|
||||||
|
(*f)(&s, s.buffer, size, ucred, tv, label, label_len);
|
||||||
|
server_done(&s);
|
||||||
|
}
|
@ -1,30 +1,10 @@
|
|||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "alloc-util.h"
|
|
||||||
#include "journald-server.h"
|
#include "journald-server.h"
|
||||||
#include "sd-event.h"
|
|
||||||
|
|
||||||
static void fuzz_journald_processing_function(
|
void fuzz_journald_processing_function(
|
||||||
const uint8_t *data,
|
const uint8_t *data,
|
||||||
size_t size,
|
size_t size,
|
||||||
void (*f)(Server *s, const char *buf, size_t raw_len, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len)
|
void (*f)(Server *s, const char *buf, size_t raw_len, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len)
|
||||||
) {
|
);
|
||||||
Server s = {};
|
|
||||||
char *label = NULL;
|
|
||||||
size_t label_len = 0;
|
|
||||||
struct ucred *ucred = NULL;
|
|
||||||
struct timeval *tv = NULL;
|
|
||||||
|
|
||||||
if (size == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
assert_se(sd_event_default(&s.event) >= 0);
|
|
||||||
s.syslog_fd = s.native_fd = s.stdout_fd = s.dev_kmsg_fd = s.audit_fd = s.hostname_fd = s.notify_fd = -1;
|
|
||||||
s.buffer = memdup_suffix0(data, size);
|
|
||||||
assert_se(s.buffer);
|
|
||||||
s.buffer_size = size + 1;
|
|
||||||
s.storage = STORAGE_NONE;
|
|
||||||
(*f)(&s, s.buffer, size, ucred, tv, label, label_len);
|
|
||||||
server_done(&s);
|
|
||||||
}
|
|
||||||
|
@ -19,12 +19,14 @@ fuzzers += [
|
|||||||
libshared],
|
libshared],
|
||||||
[libmount]],
|
[libmount]],
|
||||||
|
|
||||||
[['src/fuzz/fuzz-journald-native.c'],
|
[['src/fuzz/fuzz-journald-native.c',
|
||||||
|
'src/fuzz/fuzz-journald.c'],
|
||||||
[libjournal_core,
|
[libjournal_core,
|
||||||
libshared],
|
libshared],
|
||||||
[libselinux]],
|
[libselinux]],
|
||||||
|
|
||||||
[['src/fuzz/fuzz-journald-syslog.c'],
|
[['src/fuzz/fuzz-journald-syslog.c',
|
||||||
|
'src/fuzz/fuzz-journald.c'],
|
||||||
[libjournal_core,
|
[libjournal_core,
|
||||||
libshared],
|
libshared],
|
||||||
[libselinux]],
|
[libselinux]],
|
||||||
|
Loading…
Reference in New Issue
Block a user