From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 48A0C21CB2E2D for ; Tue, 2 Jan 2018 00:22:47 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jan 2018 00:27:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,495,1508828400"; d="scan'208";a="191563896" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga005.fm.intel.com with ESMTP; 02 Jan 2018 00:27:48 -0800 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 2 Jan 2018 00:27:47 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 2 Jan 2018 00:27:47 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by shsmsx102.ccr.corp.intel.com ([169.254.2.189]) with mapi id 14.03.0319.002; Tue, 2 Jan 2018 16:27:45 +0800 From: "Zeng, Star" To: "Wang, Jian J" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Yao, Jiewen" , "Zeng, Star" Thread-Topic: [PATCH 2/2] MdeModulePkg/DxePrintLibPrint2Protocol: Fix incomplete print output Thread-Index: AQHTg6KjP78DHXvEaEKun7zHIEYq3aNgP8Ig Date: Tue, 2 Jan 2018 08:27:44 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9E041B@SHSMSX104.ccr.corp.intel.com> References: <20180102082021.17792-1-jian.j.wang@intel.com> <20180102082021.17792-3-jian.j.wang@intel.com> In-Reply-To: <20180102082021.17792-3-jian.j.wang@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 2/2] MdeModulePkg/DxePrintLibPrint2Protocol: Fix incomplete print output X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jan 2018 08:22:47 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng Thanks, Star -----Original Message----- From: Wang, Jian J=20 Sent: Tuesday, January 2, 2018 4:20 PM To: edk2-devel@lists.01.org Cc: Gao, Liming ; Yao, Jiewen ;= Zeng, Star Subject: [PATCH 2/2] MdeModulePkg/DxePrintLibPrint2Protocol: Fix incomplete= print output This is caused by a previous patch which tried to fix string over-read. It's found that that patch for PrintLib in MdePkg will cause premature term= inating of loop used to traversing format string and cause incomplete strin= g output. Because this library uses similar code to do the same job, it has= the same issue too. So the fix is also the same. Cc: Liming Gao Cc: Jiewen Yao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang --- MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c b/Md= eModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c index 0e6178fc9c..e09520c81b 100644 --- a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c +++ b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c @@ -2051,7 +2051,9 @@ InternalPrintLibSPrintMarker ( // ArgumentString is either null-terminated, or it contains Precisio= n characters // for (Count =3D 0; - ArgumentString[Count * BytesPerArgumentCharacter] !=3D '\0' && + (ArgumentString[Count * BytesPerArgumentCharacter] !=3D '\0' |= | + (BytesPerArgumentCharacter > 1 && + ArgumentString[Count * BytesPerArgumentCharacter + 1]!=3D=20 + '\0')) && (Count < Precision || ((Flags & PRECISION) =3D=3D 0)); Count++) { ArgumentCharacter =3D ((ArgumentString[Count * BytesPerArgumentCha= racter] & 0xff) | ((ArgumentString[Count * BytesPerArgumentCharacter + 1]) = << 8)) & ArgumentMask; @@ -2110,7 +2112,9 @@ InternalPrintLibSPrintMarker ( // // Copy the string into the output buffer performing the required type= conversions // - while (Index < Count && (*ArgumentString) !=3D '\0') { + while (Index < Count && + (ArgumentString[0] !=3D '\0' || + (BytesPerArgumentCharacter > 1 && ArgumentString[1] !=3D=20 + '\0'))) { ArgumentCharacter =3D ((*ArgumentString & 0xff) | (((UINT8)*(Argumen= tString + 1)) << 8)) & ArgumentMask; =20 LengthToReturn +=3D (1 * BytesPerOutputCharacter); -- 2.15.1.windows.2