From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 4228178078E for ; Thu, 7 Sep 2023 10:33:54 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=+QEJxzPYGgWo0HPVipkwASLV+L/NnWdoHu+8QC5DoDY=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20140610; t=1694082832; v=1; b=fDzURO6YO9/fH4TpHon5MKVlIofK7ezz7Skk+QKxZNVqexJx1pT7j3141rK486vv9d44PCZu mG3H8PEGt/MtLDF0BMQmxU9TPP+d0g5nlb9bEcnZc+UKDrOm7oOK0kUuYac8T8vl9aY7NCJDf8R LcM6NKJ6S/76IywUuEObJioY= X-Received: by 127.0.0.2 with SMTP id OAykYY7687511xwzN5ietWC7; Thu, 07 Sep 2023 03:33:52 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.9646.1694082832121116107 for ; Thu, 07 Sep 2023 03:33:52 -0700 X-Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 70C87611E6 for ; Thu, 7 Sep 2023 10:33:51 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8C9EC4936D for ; Thu, 7 Sep 2023 10:33:50 +0000 (UTC) X-Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-501b9f27eb2so2397825e87.0 for ; Thu, 07 Sep 2023 03:33:50 -0700 (PDT) X-Gm-Message-State: VzNf4TvwfTkKvKAcOEGJexv5x7686176AA= X-Google-Smtp-Source: AGHT+IHGwKiX7kFKyz0GeDWuwtquaIRZnOd66PqBLS23hAlFExI44JjoKPeyZf+TV3RpIdfgCXO4nHQVwcrO91ubLB0= X-Received: by 2002:a05:6512:3b24:b0:4ff:9a91:6b73 with SMTP id f36-20020a0565123b2400b004ff9a916b73mr950492lfv.17.1694082828883; Thu, 07 Sep 2023 03:33:48 -0700 (PDT) MIME-Version: 1.0 References: <20230907033441.1915-2-mjsbeaton@gmail.com> In-Reply-To: <20230907033441.1915-2-mjsbeaton@gmail.com> From: "Ard Biesheuvel" Date: Thu, 7 Sep 2023 12:33:37 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH v5] MdeModulePkg/HiiDatabase: Fix incorrect AllocateCopyPool size To: devel@edk2.groups.io, mjsbeaton@gmail.com Cc: Eric Dong , Dandan Bi Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ardb@kernel.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=fDzURO6Y; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On Thu, 7 Sept 2023 at 05:35, Mike Beaton wrote: > > The immediately preceding call, GetBestLanguage, plus the implementation of > HiiGetString, which is called immediately afterwards, make it clear that > BestLanguage is a null-terminated ASCII string, and not just a five byte, > non-null terminated buffer. > > Therefore AsciiStrLen is one byte too short, meaning that whether the space > allocated is really sufficient and whether the resultant string is really > null-terminated becomes implementation-dependent. Rather than switching to > AsciiStrSize, we use an explicitly compile-time string length calculation > (both compile-time and run-time approaches are currently used elsewhere in > the codebase for copying static strings). > > Signed-off-by: Mike Beaton Thanks for the fix. Reviewed-by: Ard Biesheuvel > --- > MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c > index 96e05d4cf9..6e791783a6 100644 > --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c > +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c > @@ -1987,7 +1987,7 @@ GetNameFromId ( > NULL > ); > if (BestLanguage == NULL) { > - BestLanguage = AllocateCopyPool (AsciiStrLen ("en-US"), "en-US"); > + BestLanguage = AllocateCopyPool (sizeof ("en-US"), "en-US"); > ASSERT (BestLanguage != NULL); > } > > -- > 2.41.0 > > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108373): https://edk2.groups.io/g/devel/message/108373 Mute This Topic: https://groups.io/mt/101208544/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-