From nobody Wed May 8 18:38:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+80056+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80056+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1630480752; cv=none; d=zohomail.com; s=zohoarc; b=oEItBSs2AZhe/u6WcFZ0lvOOuXMNLfZF63I0iA9w5e1RDkmrfDnLzcy0KoOVMfdadLqQd0d0tt9CDNtYaU8tnH1Svbw8fsgwiOQ3MOo0PI+EUJIlD6hrxxCy5QdDQgRXQjuoEb2XjzZL+4mKVmQfCbBF8AI0nAmPcKyIR+6Bol8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630480752; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=nfi9N2N8ppsg1TNtBni45JABbK/c52t3Yp3Jjv8dAao=; b=DyqYJHQSE2VESBkX7WMVjnC+U8If0Dd61vyOjdkFQ24exUU9PdgRzoYmQuyAFy1qNqVKjgRj7+eBKEgHOuvgdZ5wiHYYwYxQEC7ziSU+pbe6+s3LXrSdS3A60T6KYA/CK2s1FZfDBnxsfABFtMuDFQHnOwq3VS3pTOfd9pZxL2c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80056+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1630480752268924.1786796408932; Wed, 1 Sep 2021 00:19:12 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id YdkXYY1788612xZy693Ip0hF; Wed, 01 Sep 2021 00:19:11 -0700 X-Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web12.4667.1630480750045099360 for ; Wed, 01 Sep 2021 00:19:11 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10093"; a="282376313" X-IronPort-AV: E=Sophos;i="5.84,368,1620716400"; d="scan'208";a="282376313" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2021 00:19:08 -0700 X-IronPort-AV: E=Sophos;i="5.84,368,1620716400"; d="scan'208";a="531980762" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.147.208]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2021 00:19:08 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Rebecca Cran , Jayaprakash Nevara Subject: [edk2-devel] [edk2-libc Patch] StdLib/LibC: Fix corner case in use of StrnCpyS() and AsciiStrnCpyS() Date: Wed, 1 Sep 2021 00:18:58 -0700 Message-Id: <20210901071858.1686-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: scU8hpwhO70lFJ4l7eaTTaPxx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1630480751; bh=JGvpRT8oMYESZETpCq+LngHxvHuPFLMfTa5fD7q0BHs=; h=Cc:Date:From:Reply-To:Subject:To; b=kwPglM8cIfTfMFUBsLZOjKzxHUNwhOt61b5Wl/8n3EnTATx2sjU9bzhujxsd+ubl3CP k9b+K00sOn4nYzIBS9mlq5bXGhHZ2+fB8b+jn2UagaFK/JPZsVKdI1N8G3IA310jxsaV4 ubMZuWsdGkN3zJxpQ/iAmR4G+OPmpP8VXR4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1630480754099100002 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3361 DestMax must be > Length or StrnCpyS() and AsciiStrnCpyS() return an error. Set DestMax to n + 1 for these LibC APIs. Cc: Rebecca Cran Cc: Jayaprakash Nevara Signed-off-by: Michael D Kinney Reviewed-by: Rebecca Cran --- StdLib/LibC/String/Copying.c | 2 +- StdLib/LibC/Wchar/Copying.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/StdLib/LibC/String/Copying.c b/StdLib/LibC/String/Copying.c index c296714..a50331b 100644 --- a/StdLib/LibC/String/Copying.c +++ b/StdLib/LibC/String/Copying.c @@ -90,7 +90,7 @@ strcpy(char * __restrict s1, const char * __restrict s2) **/ char *strncpy(char * __restrict s1, const char * __restrict s2, size_t= n) { - AsciiStrnCpyS (s1, n, s2, n); + AsciiStrnCpyS (s1, n + 1, s2, n); return s1; //char *dest =3D s1; =20 diff --git a/StdLib/LibC/Wchar/Copying.c b/StdLib/LibC/Wchar/Copying.c index 45ceda7..d5a1149 100644 --- a/StdLib/LibC/Wchar/Copying.c +++ b/StdLib/LibC/Wchar/Copying.c @@ -44,7 +44,7 @@ wchar_t *wcscpy(wchar_t * __restrict s1, const wchar_t * = __restrict s2) **/ wchar_t *wcsncpy(wchar_t * __restrict s1, const wchar_t * __restrict s2, s= ize_t n) { - return (wchar_t *)StrnCpyS ((CHAR16 *)s1, (UINTN)n, (CONST CHAR16 *)s2, = (UINTN)n); + return (wchar_t *)StrnCpyS ((CHAR16 *)s1, (UINTN)n + 1, (CONST CHAR16 *)= s2, (UINTN)n); } =20 /** The wmemcpy function copies n wide characters from the object pointed = to by --=20 2.32.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#80056): https://edk2.groups.io/g/devel/message/80056 Mute This Topic: https://groups.io/mt/85296459/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-