From nobody Sat May 4 06:52:56 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+83291+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+83291+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1635976108; cv=none; d=zohomail.com; s=zohoarc; b=I4YMOcBuR92ddb4tBGg2bVi2OFIhj4uTxJT9w5ivldcDn03E+fyyc2fLlLt1yhjrMgSidiQJRsPiIEi1PcPj+CLGAMqI10UFKIsVkYMSOZ2Jh7sJ2oCsGXaK0dM5lqrgpHHSCOinarrIXZsTctg7oC+0zV3xFiPWFgOwUBGRqtA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635976108; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=vEfMe4VG5A5SqUukIIVxGjtf1+vRWeK0PoHxeBCX4Fo=; b=Rv8ctX3bYm+bMsXmbqh/QLrCN7xWE1Y/n+/W9vqfc3YGcdLXOf5NjMz5qyjJ0XSZXuVA6eO1memi1RkO8yIYaNyQrL048UjQglYfplmm8Ej6VEtSA8G7r0ZVydh56ku935ap7FSbmL4ZIKo8cguC6I54r6VhP13ROqNUv8QMajM= 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+83291+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 1635976108115374.84300088835846; Wed, 3 Nov 2021 14:48:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id kTslYY1788612xswIxU5JPJc; Wed, 03 Nov 2021 14:48:27 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web09.4803.1635929137368097975 for ; Wed, 03 Nov 2021 01:45:37 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10156"; a="211509883" X-IronPort-AV: E=Sophos;i="5.87,205,1631602800"; d="scan'208";a="211509883" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2021 01:45:30 -0700 X-IronPort-AV: E=Sophos;i="5.87,205,1631602800"; d="scan'208";a="500951661" X-Received: from mmowka-mobl1.ger.corp.intel.com ([10.252.53.127]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2021 01:45:28 -0700 From: mateusz.mowka@intel.com To: devel@edk2.groups.io Cc: mateusz-mowka , Caleb Reister , Rebecca Cran , Michael D Kinney Subject: [edk2-devel] [PATCH] StdLib/LibC: add strnlen function wrapper Date: Wed, 3 Nov 2021 09:44:55 +0100 Message-Id: <20211103084455.468-1-mateusz.mowka@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,mateusz.mowka@intel.com X-Gm-Message-State: WdYv5Lv4yCYmXBD9z07yxD6ix1787277AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1635976107; bh=vEfMe4VG5A5SqUukIIVxGjtf1+vRWeK0PoHxeBCX4Fo=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=dcIBRrUN31NBiY99zm4vQAN5frQAVCh0g3aAoRjKlFJAD4bk+Hr74hs4AxXktzQhsU6 nHjnrnwZRHzcX9BMPNNZFI7CC2Y2V+JWkqtzlIK3Apz9nv8SEt2MQW1VbuH5FuYT2WG1R +jmqKcgG2u+asDtM2kdL17mWKbXpS7lwWeM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1635976109113100001 From: mateusz-mowka This patch adds strnlen function wrapper that internally calls AsciiStrnLenS, which is defined in BaseLib. Cc: Caleb Reister Cc: Rebecca Cran Cc: Michael D Kinney Signed-off-by: Mateusz M=C3=B3wka --- StdLib/Include/string.h | 11 +++++++++++ StdLib/LibC/String/Misc.c | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/StdLib/Include/string.h b/StdLib/Include/string.h index 0c80944..07652ca 100644 --- a/StdLib/Include/string.h +++ b/StdLib/Include/string.h @@ -62,6 +62,7 @@ void *memset (void *s, int c, size_t n); char *strerror (int num); size_t strlen (const char *); + size_t strnlen (const char, size_t n) =20 ################ BSD Compatibility Functions char *strdup (const char *); @@ -454,6 +455,16 @@ char *strerror(int Num); **/ size_t strlen(const char *S); =20 +/** The strnlen function computes the length of a fixed-size string. + + @param[in] S Pointer to the string to determine the length of. + @param[in] N Length of a string including the terminating character. + + @return The strnlen function returns the number of characters that + precede the terminating null character but not exceeding N. +**/ +size_t strnlen(const char *S, size_t N); + =20 /* ################ BSD Compatibility Functions ######################= # */ =20 diff --git a/StdLib/LibC/String/Misc.c b/StdLib/LibC/String/Misc.c index f024136..cf680e3 100644 --- a/StdLib/LibC/String/Misc.c +++ b/StdLib/LibC/String/Misc.c @@ -99,3 +99,15 @@ strlen(const char *s) { return (size_t)AsciiStrLen( s); } + +/** The strnlen function computes the length of the string pointed to by s + but at most n + + @return The strnlen function returns the number of characters that + precede the terminating null character but at most n. +**/ +size_t +strnlen(const char *s, size_t n) +{ + return (size_t)AsciiStrnLenS( s, n); +} --=20 2.28.0.windows.1 --------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydz= ial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-31= 6 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata= i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wi= adomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiek= olwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the s= ole use of the intended recipient(s). If you are not the intended recipient= , please contact the sender and delete all copies; any review or distributi= on by others is strictly prohibited. -=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 (#83291): https://edk2.groups.io/g/devel/message/83291 Mute This Topic: https://groups.io/mt/86803221/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-