All of lore.kernel.org
 help / color / mirror / Atom feed
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 v9 5/5] eficonfig: add "Show Signature Database" menu entry
Date: Thu, 17 Nov 2022 23:49:29 +0200	[thread overview]
Message-ID: <Y3asafdInDP0ILfX@hera> (raw)
In-Reply-To: <20221116102820.21021-6-masahisa.kojima@linaro.org>

Hi Kojima-san

> +/**
> + * 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];

This is going to hold a GUID right? Isn't buf[37] enough?

> +			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));

Since the lenght will always be static, just use sizeof(buf)

> +			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;
> +			}
> +			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;
 
With those 
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>



  reply	other threads:[~2022-11-17 21:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 10:28 [PATCH v9 0/5] eficonfig: add UEFI Secure Boot key maintenance interface Masahisa Kojima
2022-11-16 10:28 ` [PATCH v9 1/5] eficonfig: refactor file selection handling Masahisa Kojima
2022-11-16 10:28 ` [PATCH v9 2/5] eficonfig: expose append entry function Masahisa Kojima
2022-11-16 10:28 ` [PATCH v9 3/5] eficonfig: refactor change boot order implementation Masahisa Kojima
2022-11-16 10:28 ` [PATCH v9 4/5] eficonfig: add UEFI Secure Boot Key enrollment interface Masahisa Kojima
2022-11-17 23:07   ` Heinrich Schuchardt
2022-11-18  9:37     ` Masahisa Kojima
2022-11-18 17:30       ` Heinrich Schuchardt
2022-11-19 23:54         ` Masahisa Kojima
2022-11-16 10:28 ` [PATCH v9 5/5] eficonfig: add "Show Signature Database" menu entry Masahisa Kojima
2022-11-17 21:49   ` Ilias Apalodimas [this message]
2022-11-17 22:01     ` Heinrich Schuchardt
2022-11-18  2:18       ` Masahisa Kojima
2022-11-18  2:21         ` Masahisa Kojima
2022-11-17 23:26 ` [PATCH v9 0/5] eficonfig: add UEFI Secure Boot key maintenance interface Heinrich Schuchardt

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=Y3asafdInDP0ILfX@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.