From nobody Fri Oct 27 16:17:45 2023 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 4SH79j5llTz4yQp3; Fri, 27 Oct 2023 16:17:45 +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 4SH79j5HYBz3MdL; Fri, 27 Oct 2023 16:17:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698423465; 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=oXFV69qQzuO3gpw3atAgyiJ0tcJ/dnyQqTq22Evaw5U=; b=KIbQMK/NRmeR8YHUkxUH/lTifFfC5T692H01y9pB9XguF1hlTYAlrB+B3avlsQ3n6LDQ+f Bkn3KXANOArU4/Hp4Z4GNVPg99/59iHiR27ZbSMcyEl94TMES1fMSRaszWJQZKQrkJcuN6 XJuEDP+fD9bLWVQgKEBx1hDrMOTddW8/EJUb07MjHGmJcyT5h7k6Ge2epy0yGywhQWdd4A XyyytN6ShMhw1YpC8lkXzzwUbLXpMwTLlUNn1Uuud3E5Y4ymlRo72hT7Q0/39Ugy3dKJiy o4BQeEfEhqqZwNCY2jqHLee5MJcmbGmH/5Y9fa16h50iJTmYn1TUP9KBBxEdzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698423465; 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=oXFV69qQzuO3gpw3atAgyiJ0tcJ/dnyQqTq22Evaw5U=; b=xrXZu1A0nSrHb5GJnnhTXCFC0qwRbGi+shyHa/LJGnfe1Sdjj6MHwPfHv6cb8FjazCNOJh K/lu8APGp9Bq/yFksSvWggYsmS5qCYq/nIsa8xLznCMZlJ/g3Hqv49+swyAppWnh4wfghH xBUJd15g1TM5SAw3KTsphaF6mt9ea596+HHkqDtJHEH+uVu8Acmh+QzsTsg1jaFMI10imS DhUlJWTYLQbnyXbe/SJx/6GbtHnWpLqJ/QMdLgUsDHCQu5jKW7vUOsjy7+nEKqRLiVhnyd X00dBIctlAEmPwHKcJJJubaEAU7Sxq51RDsAqrgnd0+Yw2+cGD7hffGCK6YfHg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698423465; a=rsa-sha256; cv=none; b=eM9RIj6RXb+EByT8mOSWugwjZTlPdO4crUTUY2+kkr7/UnfKqs35i1PE8fUs9aPP0DmU1F hpSyHFwphIy8KVh0y1bhlMl72LguY1yQhOcsS6weCYKSGAEe5UnupSPOuWyoY7lAnzMOQ+ 81crX7ZerzylbUZF3wUAzWPYCG9KTh8kSQnTzQVWkffYUHyb7SwBErz7gBe1yCbt3cf9VC fhczgEQI8LpzfCzQ8QCGA0AtnvEjysXyzVZdUjAX5TXpAJxLI+v/AN8f6smuiLWBklaW/h 1kv1sG+F1ontsOV6fGakMCePlN3zsJQYBwE6osC4MtfYgZC3o+igsA/kbIAx+Q== 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 4SH79j4MPpz5rB; Fri, 27 Oct 2023 16:17:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39RGHjJS059276; Fri, 27 Oct 2023 16:17:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39RGHj3J059273; Fri, 27 Oct 2023 16:17:45 GMT (envelope-from git) Date: Fri, 27 Oct 2023 16:17:45 GMT Message-Id: <202310271617.39RGHj3J059273@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: 5e50a0f39ff7 - main - strlcpy/strlcat: Remove references to snprintf 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: 5e50a0f39ff7fce651a0d36ee686740b70ad9f0e Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=5e50a0f39ff7fce651a0d36ee686740b70ad9f0e commit 5e50a0f39ff7fce651a0d36ee686740b70ad9f0e Author: Warner Losh AuthorDate: 2023-10-27 16:11:29 +0000 Commit: Warner Losh CommitDate: 2023-10-27 16:13:50 +0000 strlcpy/strlcat: Remove references to snprintf While strlcpy and snprintf are somewhat similar, there's big differences between strlcat and snprintf which leads to confusion. Remove the comparison, since it's ultimately not that useful: the snprintf man page has similar language to strlcpy, so it doesn't provide a better reference. The two implementations are otherwise unrelated. Reviewed by: bcr Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27228 --- lib/libc/string/strlcpy.3 | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/lib/libc/string/strlcpy.3 b/lib/libc/string/strlcpy.3 index 148afcbbd2bd..89c9d62c5a25 100644 --- a/lib/libc/string/strlcpy.3 +++ b/lib/libc/string/strlcpy.3 @@ -25,7 +25,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd May 1, 2020 +.Dd October 27, 2023 .Dt STRLCPY 3 .Os .Sh NAME @@ -45,9 +45,11 @@ The .Fn strlcpy and .Fn strlcat -functions copy and concatenate strings with the -same input parameters and output result as -.Xr snprintf 3 . +functions copy and concatenate strings with the same input parameters and output result as +.Xr strcpy 3 +and +.Xr strcat 3 +with proper overflow protection. They are designed to be safer, more consistent, and less error prone replacements for the easily misused functions .Xr strncpy 3 @@ -100,22 +102,7 @@ and .Fa dst strings overlap, the behavior is undefined. .Sh RETURN VALUES -Besides quibbles over the return type -.Pf ( Va size_t -versus -.Va int ) -and signal handler safety -.Pf ( Xr snprintf 3 -is not entirely safe on some systems), the -following two are equivalent: -.Bd -literal -offset indent -n = strlcpy(dst, src, len); -n = snprintf(dst, len, "%s", src); -.Ed -.Pp -Like -.Xr snprintf 3 , -the +The .Fn strlcpy and .Fn strlcat