diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-05-07 11:08:04 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-05-08 17:58:00 +0200 |
commit | a89dd095e1dc4bece779900f7925cc2446f4c678 (patch) | |
tree | 97e9a29d3d55d1aa3cc15cfe0724ddfa9c851bd4 /src/fuzz | |
parent | fuzz-bootspec: one more test case that was fixed in strv code (diff) | |
download | systemd-a89dd095e1dc4bece779900f7925cc2446f4c678.tar.xz systemd-a89dd095e1dc4bece779900f7925cc2446f4c678.zip |
fuzz-bootspec: also add loader autoentries
Diffstat (limited to 'src/fuzz')
-rw-r--r-- | src/fuzz/fuzz-bootspec-gen.py | 5 | ||||
-rw-r--r-- | src/fuzz/fuzz-bootspec.c | 14 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/fuzz/fuzz-bootspec-gen.py b/src/fuzz/fuzz-bootspec-gen.py index aaacbbe7f5..99af3f5f69 100644 --- a/src/fuzz/fuzz-bootspec-gen.py +++ b/src/fuzz/fuzz-bootspec-gen.py @@ -7,12 +7,15 @@ import os import sys config = open(sys.argv[1]).read() +loader = [entry for entry in open(sys.argv[2], encoding='utf-16-le').read().split('\0') + if len(entry) > 2] # filter out fluff from bad decoding entries = [(os.path.basename(name), open(name).read()) - for name in sys.argv[2:]] + for name in sys.argv[3:]] data = { 'config': config, 'entries': entries, + 'loader': loader, } print(json.dumps(data, indent=4)) diff --git a/src/fuzz/fuzz-bootspec.c b/src/fuzz/fuzz-bootspec.c index 9907457450..b59e67c24e 100644 --- a/src/fuzz/fuzz-bootspec.c +++ b/src/fuzz/fuzz-bootspec.c @@ -59,9 +59,23 @@ static int json_dispatch_entries(const char *name, JsonVariant *variant, JsonDis return 0; } +static int json_dispatch_loader(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) { + BootConfig *config = ASSERT_PTR(userdata); + _cleanup_strv_free_ char **entries = NULL; + int r; + + r = json_dispatch_strv(name, variant, flags, &entries); + if (r < 0) + return r; + + (void) boot_config_augment_from_loader(config, entries, false); + return 0; +} + static const JsonDispatch data_dispatch[] = { { "config", JSON_VARIANT_STRING, json_dispatch_config, 0, 0 }, { "entries", JSON_VARIANT_ARRAY, json_dispatch_entries, 0, 0 }, + { "loader", JSON_VARIANT_ARRAY, json_dispatch_loader, 0, 0 }, {} }; |