public inbox for u-boot@lists.denx.de
 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>,
	Michal Simek <michal.simek@amd.com>,
	Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>
Subject: Re: [PATCH v7 8/9] cmd: efidebug: add uri device path
Date: Tue, 17 Oct 2023 22:27:00 +0300	[thread overview]
Message-ID: <ZS7gBMES7sBTbUu+@hades> (raw)
In-Reply-To: <20231016064526.2410856-9-masahisa.kojima@linaro.org>

Hi Kojima-san,

[...]

> +			id = (int)hextoul(argv[1], &endp);
> +			if (*endp != '\0' || id > 0xffff)
> +				return CMD_RET_USAGE;
> +
> +			efi_create_indexed_name(var_name16, sizeof(var_name16),
> +						"Boot", id);
> +
> +			label = efi_convert_string(argv[2]);
> +			if (!label)
> +				return CMD_RET_FAILURE;
> +			lo.label = label;
> +
> +			uridp_len = sizeof(struct efi_device_path) + strlen(argv[3]) + 1;
> +			fp_free = efi_alloc(uridp_len + sizeof(END));
> +			uridp = (struct efi_device_path_uri *)fp_free;
> +			uridp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
> +			uridp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_URI;
> +			uridp->dp.length = uridp_len;
> +			if (!wget_validate_uri(argv[3])) {
> +				printf("ERROR: invalid URI\n");
> +				r = CMD_RET_FAILURE;
> +				goto out;
> +			}

This needs to be moved right under label = efi_convert_string(argv[2]);
and group all the checks together early.  You won't have to allocate and
free the memory as well 

> +
> +			strcpy(uridp->uri, argv[3]);
> +			pos = (char *)uridp + uridp_len;
> +			memcpy(pos, &END, sizeof(END));
> +			fp_size += uridp_len + sizeof(END);

Assign this earlier and use it on fp_free = efi_alloc(...)

> +			file_path = (struct efi_device_path *)uridp;
> +			argc -= 3;

[...]

> + *
> + * @uri:	uri string of target file of wget
> + * Return:	true if uri is valid, false if uri is invalid
> + */
> +bool wget_validate_uri(char *uri);
> +
>  #endif /* __NET_H__ */
> diff --git a/net/wget.c b/net/wget.c
> index 2087146b37..6ae2237a0a 100644
> --- a/net/wget.c
> +++ b/net/wget.c
> @@ -566,3 +566,74 @@ out:
>  	return ret;
>  }
>  #endif
> +
 
Regards
/Ilias

  reply	other threads:[~2023-10-17 19:27 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-16  6:45 [PATCH v7 0/9] Add EFI HTTP boot support Masahisa Kojima
2023-10-16  6:45 ` [PATCH v7 1/9] net: wget: prevent overwriting reserved memory Masahisa Kojima
2023-10-16  6:45 ` [PATCH v7 2/9] net: wget: add wget with dns utility function Masahisa Kojima
2023-10-16  6:45 ` [PATCH v7 3/9] blk: blkmap: add ramdisk creation " Masahisa Kojima
2023-10-16  6:45 ` [PATCH v7 4/9] efi_loader: create default file boot option Masahisa Kojima
2023-10-16  7:06   ` Heinrich Schuchardt
2023-10-16 12:31     ` Ilias Apalodimas
2023-10-16 12:46       ` Heinrich Schuchardt
2023-10-16 12:57         ` Ilias Apalodimas
2023-10-16 13:00         ` Masahisa Kojima
2023-10-16 14:47           ` Heinrich Schuchardt
2023-10-17  5:32             ` Masahisa Kojima
2023-10-17 19:46               ` Ilias Apalodimas
2023-10-18  9:07                 ` Masahisa Kojima
2023-10-18  9:12                   ` Ilias Apalodimas
2023-10-18  9:30                     ` Heinrich Schuchardt
2023-10-19  6:45                     ` Masahisa Kojima
2023-10-19  7:22                       ` Ilias Apalodimas
2023-10-19  8:24                         ` Masahisa Kojima
2023-10-17 20:29               ` Heinrich Schuchardt
2023-10-16  6:45 ` [PATCH v7 5/9] efi_loader: support boot from URI device path Masahisa Kojima
2023-10-18  0:42   ` Heinrich Schuchardt
2023-10-18  8:32     ` Masahisa Kojima
2023-10-16  6:45 ` [PATCH v7 6/9] efi_loader: add CDROM short-form " Masahisa Kojima
2023-10-18 10:19   ` Heinrich Schuchardt
2023-10-19  3:21     ` Masahisa Kojima
2023-10-16  6:45 ` [PATCH v7 7/9] Boot var automatic management for removable medias Masahisa Kojima
2023-10-16  7:58   ` João Marcos Costa
2023-10-16 19:02     ` João Marcos Costa
2023-10-16  6:45 ` [PATCH v7 8/9] cmd: efidebug: add uri device path Masahisa Kojima
2023-10-17 19:27   ` Ilias Apalodimas [this message]
2023-10-18  8:38     ` Masahisa Kojima
2023-10-16  6:45 ` [PATCH v7 9/9] doc: uefi: add HTTP Boot support 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=ZS7gBMES7sBTbUu+@hades \
    --to=ilias.apalodimas@linaro.org \
    --cc=joe.hershberger@ni.com \
    --cc=masahisa.kojima@linaro.org \
    --cc=michal.simek@amd.com \
    --cc=rfried.dev@gmail.com \
    --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