From nobody Thu Dec 26 23:30:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+108357+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+108357+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694057722; cv=none; d=zohomail.com; s=zohoarc; b=LHhu0yw6aSzUutR8cDEuX1os/mFohIa98JQFOAkfCoWQsS6ok+2jrw2VUrUEwnqjhnEee9HBro1a+q0WYjXgZwaGuziSn58Jg8d490hMyfsnndmSxksmYy+gZbjk1b1YbWff4mn1jagTsVwElYnFKlgEAFboVB/Ud5mIuGZfgPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694057722; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=hVnrCxMuKIgMNP1JGvew16iIy7HXzPrOD/+ZNHlcfnc=; b=nJVylMeCj9Uo/vjo5r6KEj/Nqj6LDpjzUW1V2bLMmj3w2cHNSda9cygB9O/GxoA5rMNDAdllD3n633D+/ahqta4zSYz9aPi+iIfqSCa36yvvwU8D7tocDjeqq8ffGF8dSVfSfOIUi+uGK13PysbIAqJZ5pGYW+JjShlUDfCfL2I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+108357+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1694057722296344.13524506659587; Wed, 6 Sep 2023 20:35:22 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=OEYJO2S4vWsZPHbRsen7wsdTvN+pZZiuxGOflN+A5Ko=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1694057721; v=1; b=o7YsP4Tn8Mo/3mfelVg7u9YYw1fPOFtDPym4WUR+ezTQSprDJ5mNMD8P2w1IGAXADH89s2kp puv/1nfEoQ8hKWoywnSA+0Yu4Vm0Mq/l4+siKN+jr1EmZaDI6mRqsjTT2/Qe5HFEUGZCumMPORs yP1PDYEBGo0KS+CYVFty1anw= X-Received: by 127.0.0.2 with SMTP id z81mYY1788612x6OEhc4Df5D; Wed, 06 Sep 2023 20:35:21 -0700 X-Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by mx.groups.io with SMTP id smtpd.web11.5890.1694057720753341401 for ; Wed, 06 Sep 2023 20:35:21 -0700 X-Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-31f4a286ae1so478739f8f.3 for ; Wed, 06 Sep 2023 20:35:20 -0700 (PDT) X-Gm-Message-State: AuffZlz24mRLCTE3OmjDv8U3x1787277AA= X-Google-Smtp-Source: AGHT+IEuP0Ebea6Gbb/GMhLiUKIWA3pIV/TW2FhEbgJsy7mHg994VBwkqmBwzL0evKkMJR742cv94A== X-Received: by 2002:adf:e691:0:b0:317:7081:9a6a with SMTP id r17-20020adfe691000000b0031770819a6amr3680804wrm.24.1694057718703; Wed, 06 Sep 2023 20:35:18 -0700 (PDT) X-Received: from Michaels-iMac.lan ([193.219.99.195]) by smtp.gmail.com with ESMTPSA id 3-20020a05600c020300b003fc04d13242sm1182118wmi.0.2023.09.06.20.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Sep 2023 20:35:18 -0700 (PDT) From: "Mike Beaton" To: devel@edk2.groups.io Cc: Eric Dong , Dandan Bi , Ard Biesheuvel , Mike Beaton Subject: [edk2-devel] [PATCH v5] MdeModulePkg/HiiDatabase: Fix incorrect AllocateCopyPool size Date: Thu, 7 Sep 2023 04:34:42 +0100 Message-ID: <20230907033441.1915-2-mjsbeaton@gmail.com> MIME-Version: 1.0 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,mjsbeaton@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1694057723357100002 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Ard Biesheuvel Reviewed-by: Dandan Bi --- 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 =3D=3D NULL) { - BestLanguage =3D AllocateCopyPool (AsciiStrLen ("en-US"), "en-US"); + BestLanguage =3D AllocateCopyPool (sizeof ("en-US"), "en-US"); ASSERT (BestLanguage !=3D NULL); } =20 --=20 2.41.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108357): https://edk2.groups.io/g/devel/message/108357 Mute This Topic: https://groups.io/mt/101208544/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-