From nobody Wed May 3 00:29:28 2023 X-Original-To: dev-commits-src-branches@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 4Q9yWD56XQz48NSG; Wed, 3 May 2023 00:29:28 +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 4Q9yWD4bwqz3lTw; Wed, 3 May 2023 00:29:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683073768; 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=kHiAFwyqRw/puvcNMgyyG5i8uSoRWokJLwNZf9hflAM=; b=Z6Sm7rrhjx7P13oKkqNrqLYGxPTxYLYDA2cl+GOwRwDSFPD7dG2xMdgCBbog7dLwxC6Q2h 1OcqueRsngXaJZxpZ49EMU/ikmoIBdhpoXdl3xRWcPJyO1VdjyiiVhNjrM2Vc8q9YQFPuu xZ03W7cfK3Bnr8k4y5teQIr+KxTH/Vxn4Hr2BUHHWJRtdniVuKjSRTVZjxB24buOYlEuVW EO1FMjCstG+ngWOYUOGT6tpZzQpzS63u4acth+XbtZJJ3GXGc+Wuui5cZR0AE44GOclatY MQJXaJpQACIAPB5Ydy7kvxuw7n99E1EvvR+3lBdQkULyBAyhZImLd79qSWtNDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683073768; 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=kHiAFwyqRw/puvcNMgyyG5i8uSoRWokJLwNZf9hflAM=; b=NBW6ppZRyQ3IhEW8DCOBBHC0xupFgzlm10ZQGvB0N9ACklJRT73fU55M2DcGQtjOVP+5Zo aupewbfKzz/0RRh4rJhhdY+BTvoWLOIDOJXRbPxMSUuibcpVEt3A3+6G60fv4tHOZqe3if fTBboUGCKorrW+cbyp1kN1RtJ2KEffXiSOt9NgvBDJIh/L0TsPxrKukw+zy2qcxef922pH MAvDwkPRxllc1KQq0A5CzEG9Z6hNjpPU4XmTqSeOZGAkuYYuzxfZV5/q5wmkiyn40trbWx 2t3XCxi7gBxXZXIxvEZBxiRQpy7MU0FJkqpcCbSwOTHUSnEQ5i2TE2OPrKJDYg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683073768; a=rsa-sha256; cv=none; b=jLd88PRc7zfXkSRxX7nVPJBmw9zkGeoB9XVtvMwSxaQSsSgs06Bt885curnV2LBdcHVQVq 1z1ibLHhEcfQc6piKHSYsUSz225AmZY1eXSQd0cQva6LTgoSIeutx4dPfuyvfKap4X2N72 nJaNsM7uCihWgpQyPA9nCCXIsxxzoRPtof7vKSPiYvCZlqLafSRgu9Gipaew1o5C2QLjZa l5wHxJs8uhg/OcZXhm1JImvk4aoioTaPYRvCqsBaa9EOUqN07jBSw7jnkN5y/kQ43vjWiV Oc1RnA7ob5vJl6vgJKPAkNdeg17KuTnsKR69qsViy37RpEOe6Oisn+Sec9M6Uw== 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 4Q9yWD3jQfz18LG; Wed, 3 May 2023 00:29:28 +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 3430TSAe071790; Wed, 3 May 2023 00:29:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3430TSGx071789; Wed, 3 May 2023 00:29:28 GMT (envelope-from git) Date: Wed, 3 May 2023 00:29:28 GMT Message-Id: <202305030029.3430TSGx071789@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 42ed407622aa - stable/13 - libefivar: Fix a buffer overread. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 42ed407622aa53f9794b9d3d378c725945d27623 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=42ed407622aa53f9794b9d3d378c725945d27623 commit 42ed407622aa53f9794b9d3d378c725945d27623 Author: John Baldwin AuthorDate: 2022-10-03 23:10:44 +0000 Commit: John Baldwin CommitDate: 2023-05-02 23:46:37 +0000 libefivar: Fix a buffer overread. DevPathToTextUsbWWID allocates a separate copy of the SerialNumber string to append a null terminator if the original string is not null terminated. However, by using AllocateCopyPool, it tries to copy 'Length + 1' words from the existing string containing 'Length' characters into the target string. Split the copy out to only copy 'Length' characters instead. Reviewed by: imp, emaste Reported by: GCC 12 -Wstringop-overread Differential Revision: https://reviews.freebsd.org/D36826 (cherry picked from commit d30a1689f5b37e78ea189232a8b94a7011dc0dc8) --- lib/libefivar/efivar-dp-format.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libefivar/efivar-dp-format.c b/lib/libefivar/efivar-dp-format.c index 14f6adc2fd98..c6bb0f9dba7d 100644 --- a/lib/libefivar/efivar-dp-format.c +++ b/lib/libefivar/efivar-dp-format.c @@ -1008,9 +1008,10 @@ DevPathToTextUsbWWID ( // // In case no NULL terminator in SerialNumber, create a new one with NULL terminator // - NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr); + NewStr = AllocatePool ((Length + 1) * sizeof (CHAR16)); ASSERT (NewStr != NULL); - NewStr [Length] = 0; + CopyMem (NewStr, SerialNumberStr, Length * sizeof (CHAR16)); + NewStr[Length] = 0; SerialNumberStr = NewStr; }