From nobody Sun Feb 27 16:47:55 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 88CE819EA74C; Sun, 27 Feb 2022 16:47:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K68Zh3P3jz4m1C; Sun, 27 Feb 2022 16:47:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645980476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4ClclKWRzI9xbklZXVdOxEW4/HOZf7C9lPcTRntYiBk=; b=e8+99DTdr4jZtvl/USrSWhFJmXlnId6s4bzv0oVxgIxinY7LTkN13cp6lc/uBG84jIHJ3K 2Cvd0OdetWVN4A1jZ2UpM3w2xc4Zo5/3vgZD/FWCVO5KYL6ySZz7A7uU4k9Ho4Sn9R9+WV iizyMNdzI5oQqy8NcIP1AbJpzrKZprnvr6TGguDjUBZHJhBheG0gNGfMYsbJ7BnBh6gESn Cv5JD39sxP2I7e4QDBi2xcgWwi4eZ45XIXTgcL4mQw8TREGLPBKxai2y6d5rGigIXeLqph /sZqS/iG5LpWcozyMW9DwohA+NJnBYpPGy/bnDvBwgOPXoyBz5QR7evnNRLL0Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 60A0F2AD0; Sun, 27 Feb 2022 16:47:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21RGltPn037081; Sun, 27 Feb 2022 16:47:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21RGltfP037080; Sun, 27 Feb 2022 16:47:55 GMT (envelope-from git) Date: Sun, 27 Feb 2022 16:47:55 GMT Message-Id: <202202271647.21RGltfP037080@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: e871598ad449 - main - libefivar: Check Length para before use in DevPathToTextUsbWWID List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e871598ad4493991404bbaa030f66bfe32aca892 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645980476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4ClclKWRzI9xbklZXVdOxEW4/HOZf7C9lPcTRntYiBk=; b=CUUwMbgirIC0Dyh+E+ueltsos9hnLH0NBvsbyb0bG4wnmS1rHP9hQHNYs6TkaHmZwxGr58 impqwTAFVHSXsLoaPR+ekAT1nUyXu8G1DQp4iWO4mms2SFah7J3PRKd80pE/jaM6nAUeJr K5/gy7ZfNZCWzL90HS+5bs9ZzNn2bZDDFABvySyXY7G3ZW0kY48NjEG+CZHu+vgrylqu3x dTOSUVuW+UEkjsRxfg2y9QjhHVyfv4cdRkm3w/asVYSOQYiijg0p2UmYZTjNtkP8j6gDNx noCGnhfzhC4Xgxw0fE3d/UyZ2PsNRahPgRUlIWcZJuQ5EAggyzeo+ZZ9mF000w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645980476; a=rsa-sha256; cv=none; b=H3Q9VP+KZSCQHCbgv75fLe3FfKTvh5ObPUunS0e5oXgdeZkjtRB1yopiuJJpDM+wzjCNr4 50HNZ04dpIX+/58QYk1k1nwKuspwMGR9pLOSkEY9mpS8jdBwvj6Omi6RDv6QC23FhZ0ctx ieLI/hPIUrH9wYLpvv7j7IsjzmDubDpjj5X3SPMJzvTv86OVRt3PkRpco/Lo/jNirD0Mw8 akCt3UQNGu0QyOOr2ECnLcZVs8+T0QNLi0x6B22nzwjeRDBFSZ/0QxzszvxU/UPWbORbtE gKHjQ3z3kxJDnlN3KDdneiooCThmMhOynFVhe9uMX8tshMuA/NHYThe2OCLZXw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e871598ad4493991404bbaa030f66bfe32aca892 commit e871598ad4493991404bbaa030f66bfe32aca892 Author: Jose Luis Duran AuthorDate: 2022-02-23 20:16:15 +0000 Commit: Warner Losh 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 //