1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-24 06:04:05 +03:00

fuzz: add nspawn-settings fuzzer

This commit is contained in:
Frantisek Sumsal 2019-03-11 12:43:20 +01:00
parent 04ddab1462
commit b5b499b32c
3 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,28 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <errno.h>
#include "alloc-util.h"
#include "fd-util.h"
#include "fuzz.h"
#include "nspawn-settings.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_(settings_freep) Settings *s = NULL;
if (size == 0)
return 0;
f = fmemopen((char*) data, size, "re");
assert_se(f);
/* We don't want to fill the logs with messages about parse errors.
* Disable most logging if not running standalone */
if (!getenv("SYSTEMD_LOG_LEVEL"))
log_set_max_level(LOG_CRIT);
(void) settings_load(f, "/dev/null", &s);
return 0;
}

View File

@ -124,4 +124,9 @@ fuzzers += [
[['src/fuzz/fuzz-hostname-util.c'],
[libshared],
[]],
[['src/fuzz/fuzz-nspawn-settings.c'],
[libshared,
libnspawn_core],
[]],
]

View File

@ -0,0 +1,36 @@
[Exec]
Boot=off
ProcessTwo=off
Parameters=/sbin/init -x=1
Environment=THIS=that
User=user
WorkingDirectory=/cwd
PivotRoot=/newroot
Capability=CAP_NET
DropCapability=CAP_ADMIN
KillSignal=SIGTERM
Personality=shy
MachineID=edbfea3309ba41ea83e2318c58a8d498
PrivateUser=1:2
NotifyReady=no
SystemCallFilters=write
[Files]
ReadOnly=no
Volatile=no
Bind=/bindthis
BindReadOnly=/bindthisro
TemporaryFileSystem=/thisismytmpfs:rw
Overlay=/thisisanoverlay:/thisisanoverlaytoo
PrivateUsersChown=no
[Network]
Private=off
VirtualEthernet=yes
VirtualEthernetExtra=veth1:veth2
Interface=eth1 enp0s1
MacVLAN=eno1 eno2
IPVLAN=eno3 enp2s124
Bridge=bridge123 bridge125
Zone=myzone
Port=1234 156 -1