git: e871598ad449 - main - libefivar: Check Length para before use in DevPathToTextUsbWWID
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 27 Feb 2022 16:47:55 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e871598ad4493991404bbaa030f66bfe32aca892 commit e871598ad4493991404bbaa030f66bfe32aca892 Author: Jose Luis Duran <jlduran@gmail.com> AuthorDate: 2022-02-23 20:16:15 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2022-02-27 16:13:40 +0000 libefivar: Check Length para before use in DevPathToTextUsbWWID In function DevPathToTextUsbWWID, the Length parameter is used without check. This patch is to add check before using it. Upstream Bug: https://bugzilla.tianocore.org/show_bug.cgi?id=1336 Obtained from: https://github.com/tianocore/edk2/commit/d8e702693a8c292220131dc4234a36e2c9fff614 Pull Request: https://github.com/freebsd/freebsd-src/pull/581 --- lib/libefivar/efivar-dp-format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libefivar/efivar-dp-format.c b/lib/libefivar/efivar-dp-format.c index 9c1969d81423..c3fa492d4c24 100644 --- a/lib/libefivar/efivar-dp-format.c +++ b/lib/libefivar/efivar-dp-format.c @@ -1033,7 +1033,7 @@ DevPathToTextUsbWWID ( SerialNumberStr = (CHAR16 *) (&UsbWWId + 1); 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 //