From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 0FAD621193094 for ; Mon, 19 Nov 2018 19:49:25 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2018 19:49:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,255,1539673200"; d="scan'208";a="282554738" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga006.fm.intel.com with ESMTP; 19 Nov 2018 19:49:25 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 19 Nov 2018 19:49:25 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.117]) by shsmsx102.ccr.corp.intel.com ([169.254.2.84]) with mapi id 14.03.0415.000; Tue, 20 Nov 2018 11:49:23 +0800 From: "Gao, Liming" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" Thread-Topic: [patch] MdePkg: check Length para before use in DevPathToTextUsbWWID Thread-Index: AQHUf6zYMrGe6W6wFEe/AWvk8Q/20qVYCKCQ Date: Tue, 20 Nov 2018 03:49:22 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E36EF2F@SHSMSX104.ccr.corp.intel.com> References: <20181119020833.22748-1-dandan.bi@intel.com> In-Reply-To: <20181119020833.22748-1-dandan.bi@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNGQ3ZTBiZGUtMjliOS00ZTg2LThhODktOTI1NzlmODVjZTAxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiM2RoVGRMQm5IdlV0eUJPa0xMZHVoZUxSYWM5WExqSEdlMTE4NTR4c1ROeG1FMnVpc0ljelhVSTA3RG1sVEtFYiJ9 dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch] MdePkg: check Length para before use in DevPathToTextUsbWWID X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Nov 2018 03:49:26 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Bi, Dandan > Sent: Monday, November 19, 2018 10:09 AM > To: edk2-devel@lists.01.org > Cc: Kinney, Michael D ; Gao, Liming > Subject: [patch] MdePkg: check Length para before use in DevPathToTextUsb= WWID >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1336 >=20 > In function DevPathToTextUsbWWID, the Length parameter is used > without check. This patch is to add check before using it. >=20 > Cc: Michael D Kinney > Cc: Liming Gao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Dandan Bi > --- > MdePkg/Library/UefiDevicePathLib/DevicePathToText.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c b/MdePkg= /Library/UefiDevicePathLib/DevicePathToText.c > index 97d279eeb2..678f3d0a92 100644 > --- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c > +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c > @@ -970,11 +970,11 @@ DevPathToTextUsbWWID ( >=20 > UsbWWId =3D DevPath; >=20 > SerialNumberStr =3D (CHAR16 *) ((UINT8 *) UsbWWId + sizeof (USB_WWID_D= EVICE_PATH)); > Length =3D (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL = *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) / > sizeof (CHAR16)); > - if (SerialNumberStr [Length - 1] !=3D 0) { > + if (Length >=3D 1 && SerialNumberStr [Length - 1] !=3D 0) { > // > // In case no NULL terminator in SerialNumber, create a new one with= NULL terminator > // > NewStr =3D AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialN= umberStr); > ASSERT (NewStr !=3D NULL); > -- > 2.18.0.windows.1