From nobody Sat Nov 2 14:38:09 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1487567186783637.5029830960573; Sun, 19 Feb 2017 21:06:26 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9B038821EA; Sun, 19 Feb 2017 21:06:25 -0800 (PST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AA114821C5 for ; Sun, 19 Feb 2017 21:06:23 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Feb 2017 21:06:23 -0800 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga002.fm.intel.com with ESMTP; 19 Feb 2017 21:06:22 -0800 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,184,1484035200"; d="scan'208";a="1132212653" From: Dandan Bi To: edk2-devel@lists.01.org Date: Mon, 20 Feb 2017 13:05:49 +0800 Message-Id: <1487567149-274444-2-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1487567149-274444-1-git-send-email-dandan.bi@intel.com> References: <1487567149-274444-1-git-send-email-dandan.bi@intel.com> Subject: [edk2] [patch] MdeModulePkg/HiiDatabase: clean the value before setting default string X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Dong , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For string op-code, the default string may not exceed the maximum size, so when generating string, we should clean the value before setting the default string. https://bugzilla.tianocore.org/show_bug.cgi?id=3D375 Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeMod= ulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index d547f42..1878106 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -1,9 +1,9 @@ /** @file Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL. =20 -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at http://opensource.org/licenses/bsd-license.php =20 @@ -3696,21 +3696,29 @@ GenerateAltConfigResp ( // Convert Value to a hex string in "%x" format // NOTE: This is in the opposite byte that GUID and PATH use // if (BlockData->OpCode =3D=3D EFI_IFR_STRING_OP){ DefaultString =3D InternalGetString(HiiHandle, DefaultValueDat= a->Value.string); - TmpBuffer =3D (UINT8 *) DefaultString; + TmpBuffer =3D AllocateZeroPool (Width); + ASSERT (TmpBuffer !=3D NULL); + if (DefaultString !=3D NULL) { + CopyMem (TmpBuffer, (UINT8 *) DefaultString, StrLen(DefaultStr= ing)* sizeof (CHAR16)); + } } else { TmpBuffer =3D (UINT8 *) &(DefaultValueData->Value); } for (; Width > 0 && (TmpBuffer !=3D NULL); Width--) { StringPtr +=3D UnicodeValueToString (StringPtr, PREFIX_ZERO | RA= DIX_HEX, TmpBuffer[Width - 1], 2); } if (DefaultString !=3D NULL){ FreePool(DefaultString); DefaultString =3D NULL; } + if (BlockData->OpCode =3D=3D EFI_IFR_STRING_OP && TmpBuffer !=3D N= ULL) { + FreePool(TmpBuffer); + TmpBuffer =3D NULL; + } } } } =20 HiiToLower (*DefaultAltCfgResp); --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel