Re: [PATCH 3/5] efi: do variable name validation tests in utf8

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 04 Feb, at 10:34:32AM, Peter Jones wrote:
> Actually translate from ucs2 to utf8 before doing the test, and then
> test against our other utf8 data, instead of fudging it.
> 
> Signed-off-by: Peter Jones <pjones@xxxxxxxxxx>
> Tested-by: Lee, Chun-Yi <jlee@xxxxxxxx>
> Acked-by: Matthew Garrett <mjg59@xxxxxxxxxx>
> ---
>  drivers/firmware/efi/vars.c | 25 +++++++++++++++++--------
>  1 file changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
> index 70a0fb1..36c5a6e 100644
> --- a/drivers/firmware/efi/vars.c
> +++ b/drivers/firmware/efi/vars.c
> @@ -192,7 +192,15 @@ bool
>  efivar_validate(efi_char16_t *var_name, u8 *data, unsigned long len)
>  {
>  	int i;
> -	u16 *unicode_name = var_name;
> +	unsigned long utf8_size;
> +	u8 *utf8_name;
> +
> +	utf8_size = ucs2_utf8size(var_name);
> +	utf8_name = kmalloc(utf8_size + 1, GFP_KERNEL);
> +	if (!utf8_name)
> +		return false;
> +
> +	ucs2_as_utf8(utf8_name, var_name, len);

The use of 'len' here is incorrect. 'len' is actually ->DataSize if
you follow the call stack down from efivar_create(). Yeah, it's poorly
named.

What you actually want to be using here is 'utf8_size'. Furthermore,
ucs2_as_utf8() doesn't guarantee NUL termination, so you need to
handle that.
--
To unsubscribe from this list: send the line "unsubscribe linux-efi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux