From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Masahisa Kojima <masahisa.kojima@linaro.org>
Cc: u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
Simon Glass <sjg@chromium.org>,
Takahiro Akashi <takahiro.akashi@linaro.org>,
Etienne Carriere <etienne.carriere@linaro.org>
Subject: Re: [PATCH v8 5/5] eficonfig: add "Show Signature Database" menu entry
Date: Fri, 11 Nov 2022 14:53:44 +0200 [thread overview]
Message-ID: <Y25F2DcyRuuRyMHH@hera> (raw)
In-Reply-To: <20221110083054.11950-6-masahisa.kojima@linaro.org>
[...]
> +/**
> + * prepare_signature_list_menu() - create the signature list menu entry
> + *
> + * @efimenu: pointer to the efimenu structure
> + * @varname: pointer to the variable name
> + * @db: pointer to the variable raw data
> + * @db_size: variable data size
> + * @func: callback of each entry
> + * Return: status code
> + */
> +static efi_status_t prepare_signature_list_menu(struct efimenu *efi_menu, void *varname,
> + void *db, efi_uintn_t db_size,
> + eficonfig_entry_func func)
> +{
> + u32 num = 0;
> + efi_uintn_t size;
> + struct eficonfig_sig_data *sg;
> + struct efi_signature_list *esl;
> + struct efi_signature_data *esd;
> + efi_status_t ret = EFI_SUCCESS;
> +
> + INIT_LIST_HEAD(&efi_menu->list);
> +
> + esl = db;
> + size = db_size;
> + while (size > 0) {
> + u32 remain;
> +
> + esd = (struct efi_signature_data *)((u8 *)esl +
> + (sizeof(struct efi_signature_list) +
> + esl->signature_header_size));
> + remain = esl->signature_list_size - sizeof(struct efi_signature_list) -
> + esl->signature_header_size;
> + for (; remain > 0; remain -= esl->signature_size) {
> + char buf[40];
> + char *title;
> +
> + if (num >= EFICONFIG_ENTRY_NUM_MAX - 1) {
> + ret = EFI_OUT_OF_RESOURCES;
> + goto out;
> + }
> +
> + sg = calloc(1, sizeof(struct eficonfig_sig_data));
> + if (!sg) {
> + ret = EFI_OUT_OF_RESOURCES;
> + goto err;
> + }
> +
> + snprintf(buf, sizeof(buf), "%pUL", &esd->signature_owner);
> + title = calloc(1, (strlen(buf) + 1));
> + if (!title) {
> + free(sg);
> + ret = EFI_OUT_OF_RESOURCES;
> + goto err;
> + }
> + strlcpy(title, buf, strlen(buf) + 1);
> +
> + sg->esl = esl;
> + sg->esd = esd;
> + sg->varname = varname;
> + ret = eficonfig_append_menu_entry(efi_menu, title, func, sg);
> + if (ret != EFI_SUCCESS) {
> + free(sg);
> + free(title);
> + goto err;
> + }
title and sg are allocated on a for loop. I assume that those will
eventually be freed by eficonfig_destroy(). But shouldn't we call that on
failures as well instead of just freeing the last instance?
> + esd = (struct efi_signature_data *)((u8 *)esd + esl->signature_size);
> + num++;
> + }
> +
> + size -= esl->signature_list_size;
> + esl = (struct efi_signature_list *)((u8 *)esl + esl->signature_list_size);
> + }
> +out:
> + ret = eficonfig_append_quit_entry(efi_menu);
> +err:
> + return ret;
> +}
> +
> +/**
[...]
Regards
/Ilias
next prev parent reply other threads:[~2022-11-11 12:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 8:30 [PATCH v8 0/5] eficonfig: add UEFI Secure Boot key maintenance interface Masahisa Kojima
2022-11-10 8:30 ` [PATCH v8 1/5] eficonfig: refactor file selection handling Masahisa Kojima
2022-11-10 8:30 ` [PATCH v8 2/5] eficonfig: expose append entry function Masahisa Kojima
2022-11-10 8:30 ` [PATCH v8 3/5] eficonfig: refactor change boot order implementation Masahisa Kojima
2022-11-10 8:30 ` [PATCH v8 4/5] eficonfig: add UEFI Secure Boot Key enrollment interface Masahisa Kojima
2022-11-11 12:33 ` Ilias Apalodimas
2022-11-14 0:49 ` Masahisa Kojima
2022-11-10 8:30 ` [PATCH v8 5/5] eficonfig: add "Show Signature Database" menu entry Masahisa Kojima
2022-11-11 12:53 ` Ilias Apalodimas [this message]
2022-11-14 1:33 ` Masahisa Kojima
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y25F2DcyRuuRyMHH@hera \
--to=ilias.apalodimas@linaro.org \
--cc=etienne.carriere@linaro.org \
--cc=masahisa.kojima@linaro.org \
--cc=sjg@chromium.org \
--cc=takahiro.akashi@linaro.org \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox