summaryrefslogtreecommitdiff
path: root/mok.c
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2024-05-15 16:01:34 -0400
committerPeter Jones <pjones@redhat.com>2025-02-24 15:24:24 -0500
commit887c0edab93c52e2558047897847166b73dc8c3a (patch)
treebb9ae0f39cfa003758c1b709b7c16b121a264526 /mok.c
parent49db3de08ef2c55f6dbc3c2b8e6ab7b2f22e5309 (diff)
downloadefi-boot-shim-887c0edab93c52e2558047897847166b73dc8c3a.tar.gz
efi-boot-shim-887c0edab93c52e2558047897847166b73dc8c3a.zip
mok variables: add a format callback
This adds a member to the mok_state_variable struct to provide a callback function for formatting external data. It basically has snprintf()-like semantics for filling the buffer, but without the actual printf-like formatting bits. Signed-off-by: Peter Jones <pjones@redhat.com>
Diffstat (limited to 'mok.c')
-rw-r--r--mok.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/mok.c b/mok.c
index 2778cd05..67a798a3 100644
--- a/mok.c
+++ b/mok.c
@@ -985,8 +985,22 @@ EFI_STATUS import_one_mok_state(struct mok_state_variable *v,
}
}
+ if (v->format) {
+ v->data_size = v->format(NULL, 0, v);
+ if (v->data_size > 0) {
+ v->data = AllocatePool(v->data_size);
+ if (!v->data) {
+ perror(L"Could not allocate %lu bytes for %s\n",
+ v->data_size, v->name);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ }
+ v->format(v->data, v->data_size, v);
+ }
+
if (!v->data && !v->data_size &&
- (v->flags & MOK_VARIABLE_CONFIG_ONLY)) {
+ (v->flags & MOK_VARIABLE_CONFIG_ONLY) &&
+ !v->format) {
efi_status = get_variable_attr(v->name,
&v->data, &v->data_size,
*v->guid, &attrs);