From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02073C4332F for ; Mon, 19 Dec 2022 09:15:22 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9F52B84A16; Mon, 19 Dec 2022 10:15:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="XWLzD3eT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3372B84D70; Mon, 19 Dec 2022 10:15:19 +0100 (CET) Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D2CA481A0C for ; Mon, 19 Dec 2022 10:15:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ej1-x629.google.com with SMTP id m18so19927919eji.5 for ; Mon, 19 Dec 2022 01:15:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=PUoV/x+2Rv6Ad0lgVfA+xjNY1Q1/yk8C2/OcnAQIieU=; b=XWLzD3eTMy43YWx2Xrh54IZKw26Ylm7K3HbDwoFVIDI9eXq4w+6/gq9/+kpz7Zpz2v luHPr2Z+4WFNd3I8acTD28sHo+Dv0yU1DoHzn4oanxmMMx9+y+JJMLXtKH2YfG6QXlNi VhUlo6aiQWRbBC6yi7/2LZKaqlt/flepoMGGxqbcxcPoYAhqpcSkhC+GpJwq3R97J7zC HmLk2pSvyzd86N+s2CTyNOxJmkjp6EUcCNwUkRUmg2onlAWEnqoFr8eSw4nRyO3nbdB0 CECwiOlMTnZtTEQFluxmQp73b7AcNNJ4vcbqgX0Dd0AC4qkx+2qXOFRb8DdHwpptEL0C DbCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PUoV/x+2Rv6Ad0lgVfA+xjNY1Q1/yk8C2/OcnAQIieU=; b=3P5/Q343eeVu3dnXKcY4GGa9Q5yWP+xRlamg5UzzFJHRIYeGt6qHYdPpF97ZSmOfgw mKoOkTrIDgBdkEoPKc+j9O2hTrpX/bS7GXwA5XpzKF3gYU2mRYBZ0sIurh/DeNU0tizc aWfh/BPe1rn5Fqno7wmgRZyKQwLDJperxfWD2bcqLI5qeI+ZHV4vngFY/knujmw4L4OO yGxh8bsbSxIi1l/Eq99WZaZNmCJVTCTsLSuWCgfc/w5WuweJxeevdB5xAP0+CJ8nCqgg co3Yofvz8NhtcbLdrEqixAzrBwxObAh2IAhuRqha4rLpPm6xd78+Kq9YfSQ5slKUgjnF mx0Q== X-Gm-Message-State: ANoB5pmNiQjBuJy0J2UGoYzkCyrhTZUPrQSh6LLo47AWehT7Qd1f3tQ5 dLPlFAzAbF0qTHydKFkO+xb7IiY1KWtLADY3 X-Google-Smtp-Source: AA0mqf5GWMyG0ea+Ty5073xiRLQMWbBzmhhwHWvqwOZljY69AcHOLQzfB4jVKAiT3Ahb6dS/a0Lbbg== X-Received: by 2002:a17:906:1e42:b0:7ad:e52c:12e6 with SMTP id i2-20020a1709061e4200b007ade52c12e6mr33560792ejj.41.1671441316376; Mon, 19 Dec 2022 01:15:16 -0800 (PST) Received: from hera (ppp078087234022.access.hol.gr. [78.87.234.22]) by smtp.gmail.com with ESMTPSA id f22-20020a17090631d600b007aece68483csm4081312ejf.193.2022.12.19.01.15.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 01:15:15 -0800 (PST) Date: Mon, 19 Dec 2022 11:15:13 +0200 From: Ilias Apalodimas To: Heinrich Schuchardt Cc: u-boot@lists.denx.de Subject: Re: [PATCH 1/2] efi_loader: fix efi_get_next_variable_name_mem() Message-ID: References: <20221218060858.25578-1-heinrich.schuchardt@canonical.com> <20221218060858.25578-2-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221218060858.25578-2-heinrich.schuchardt@canonical.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Sun, Dec 18, 2022 at 06:08:57AM +0000, Heinrich Schuchardt wrote: > The VariableNameSize parameter is in bytes but u16_strnlen() counts u16. > > Fix the parameter check for null termination. > > Signed-off-by: Heinrich Schuchardt > --- > include/efi_variable.h | 3 ++- > lib/efi_loader/efi_var_mem.c | 6 +++--- > 2 files changed, 5 insertions(+), 4 deletions(-) > > diff --git a/include/efi_variable.h b/include/efi_variable.h > index 03a3ecb235..805e6c5f1e 100644 > --- a/include/efi_variable.h > +++ b/include/efi_variable.h > @@ -268,7 +268,8 @@ const efi_guid_t *efi_auth_var_get_guid(const u16 *name); > * efi_get_next_variable_name_mem() - Runtime common code across efi variable > * implementations for GetNextVariable() > * from the cached memory copy > - * @variable_name_size: size of variable_name buffer in byte > + * > + * @variable_name_size: size of variable_name buffer in bytes > * @variable_name: name of uefi variable's name in u16 > * @vendor: vendor's guid > * > diff --git a/lib/efi_loader/efi_var_mem.c b/lib/efi_loader/efi_var_mem.c > index 13909b1d26..0bac594e00 100644 > --- a/lib/efi_loader/efi_var_mem.c > +++ b/lib/efi_loader/efi_var_mem.c > @@ -315,14 +315,14 @@ efi_get_next_variable_name_mem(efi_uintn_t *variable_name_size, > u16 *variable_name, efi_guid_t *vendor) > { > struct efi_var_entry *var; > - efi_uintn_t old_size; > + efi_uintn_t len, old_size; > u16 *pdata; > > if (!variable_name_size || !variable_name || !vendor) > return EFI_INVALID_PARAMETER; > > - if (u16_strnlen(variable_name, *variable_name_size) == > - *variable_name_size) > + len = *variable_name_size >> 1; > + if (u16_strnlen(variable_name, len) == len) > return EFI_INVALID_PARAMETER; > > if (!efi_var_mem_find(vendor, variable_name, &var) && *variable_name) > -- > 2.37.2 > Reviewed-by: Ilias Apalodimas