From: "Gao, Liming" <liming.gao@intel.com>
To: "Bi, Dandan" <dandan.bi@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: [patch] MdePkg: check Length para before use in DevPathToTextUsbWWID
Date: Tue, 20 Nov 2018 03:49:22 +0000 [thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E36EF2F@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20181119020833.22748-1-dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
> -----Original Message-----
> From: Bi, Dandan
> Sent: Monday, November 19, 2018 10:09 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [patch] MdePkg: check Length para before use in DevPathToTextUsbWWID
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1336
>
> In function DevPathToTextUsbWWID, the Length parameter is used
> without check. This patch is to add check before using it.
>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
> MdePkg/Library/UefiDevicePathLib/DevicePathToText.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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 (
>
> UsbWWId = DevPath;
>
> SerialNumberStr = (CHAR16 *) ((UINT8 *) UsbWWId + sizeof (USB_WWID_DEVICE_PATH));
> Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) /
> sizeof (CHAR16));
> - if (SerialNumberStr [Length - 1] != 0) {
> + if (Length >= 1 && SerialNumberStr [Length - 1] != 0) {
> //
> // In case no NULL terminator in SerialNumber, create a new one with NULL terminator
> //
> NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);
> ASSERT (NewStr != NULL);
> --
> 2.18.0.windows.1
prev parent reply other threads:[~2018-11-20 3:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-19 2:08 [patch] MdePkg: check Length para before use in DevPathToTextUsbWWID Dandan Bi
2018-11-19 2:08 ` [patch] MdePkg: Check input Ptrs in GetSectionFromAnyFvByFileType Dandan Bi
2018-11-20 3:51 ` Gao, Liming
2018-11-20 3:49 ` Gao, Liming [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14E36EF2F@SHSMSX104.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox