summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-05-07 11:08:04 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-05-08 17:58:00 +0200
commita89dd095e1dc4bece779900f7925cc2446f4c678 (patch)
tree97e9a29d3d55d1aa3cc15cfe0724ddfa9c851bd4
parent13dcfbd32dc57cea89ac68140c4db32461e86862 (diff)
downloadsystemd-a89dd095e1dc4bece779900f7925cc2446f4c678.tar.gz
fuzz-bootspec: also add loader autoentries
-rw-r--r--src/fuzz/fuzz-bootspec-gen.py5
-rw-r--r--src/fuzz/fuzz-bootspec.c14
-rw-r--r--test/fuzz/fuzz-bootspec/sample15
3 files changed, 23 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 },
{}
};
diff --git a/test/fuzz/fuzz-bootspec/sample1 b/test/fuzz/fuzz-bootspec/sample1
index 319c5530ab..1231c864df 100644
--- a/test/fuzz/fuzz-bootspec/sample1
+++ b/test/fuzz/fuzz-bootspec/sample1
@@ -13,5 +13,10 @@
"listing.conf",
"title Title\nversion 3.7.2-201.fc18.x86_64\nmachine-id 4098b3f648d74c13b1f04ccfba7798e8\nsort-key 666\nlinux /6a9857a393724b7a981ebb5b8495b9ea/3.8.0-2.fc19.x86_64/linux\ninitrd /6a9857a393724b7a981ebb5b8495b9ea/3.8.0-2.fc19.x86_64/initrd\nefi /6a9857a393724b7a981ebb5b8495b9ea/3.8.0-2.fc19.x86_64/efi\noptions one two three four\ndevicetree 6a9857a393724b7a981ebb5b8495b9ea/3.8.0-2.fc19.armv7hl/tegra20-paz00.dtb\ndevicetree-overlay /6a9857a393724b7a981ebb5b8495b9ea/overlays/overlay_A.dtbo /6a9857a393724b7a981ebb5b8495b9ea/overlays/overlay_B.dtbo\narchitecture IA32\narchitecture x64\narchitecture IA64\narchitecture ARM\narchitecture AA64\n"
]
+ ],
+ "loader": [
+ "08a5690a2eed47cf92ac0a5d2e3cf6b0-5.17.0-0.rc5.102.fc36.x86_64.conf",
+ "08a5690a2eed47cf92ac0a5d2e3cf6b0-5.15.14-200.fc35.x86_64.conf",
+ "auto-reboot-to-firmware-setup"
]
}