From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 66DD23858D1E for ; Sat, 31 Dec 2022 15:13:46 +0000 (GMT) Content-Type: multipart/signed; boundary="Apple-Mail=_2A887ADB-5F72-4CDC-AEC0-28B2922C56A2"; protocol="application/pgp-signature"; micalg=pgp-sha512 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.101.1.3\)) Subject: Re: [PATCH 1/1] string: Add stpecpy(3) From: Sam James In-Reply-To: <674a24d3-f81b-0201-097e-0bbe9b60d1fd@gmail.com> Date: Sat, 31 Dec 2022 15:13:30 +0000 Cc: Alejandro Colomar , Florian Weimer , Paul Eggert , Libc-alpha Message-Id: References: <20221222214217.1619716-1-alx@kernel.org> <20221222214217.1619716-2-alx@kernel.org> <505B9E19-7065-4DBE-A980-3FDA096C6449@gentoo.org> <674a24d3-f81b-0201-097e-0bbe9b60d1fd@gmail.com> To: Alejandro Colomar X-Mailer: Apple Mail (2.3731.300.101.1.3) X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --Apple-Mail=_2A887ADB-5F72-4CDC-AEC0-28B2922C56A2 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On 23 Dec 2022, at 12:26, Alejandro Colomar via Libc-alpha = wrote: >=20 > Hi Sam! >=20 > On 12/23/22 08:02, Sam James wrote: >>> On 22 Dec 2022, at 21:42, Alejandro Colomar via Libc-alpha = wrote: >>>=20 >>> Glibc didn't provide any function that copies a string with = truncation. >>>=20 >>> It only provided strncpy(3) and stpncpy(3), which copy from a string >>> into a null-padded character sequence at the destination fixed-width >>> buffer, with truncation. >>>=20 >>> Those old functions, which don't produce a string, have been misused = for >>> a long time as a poor-man's replacement for strlcpy(3), but doing = that >>> is a source of bugs, since it's hard to calculate the right size = that >>> should be passed to the function, and it's also necessary to = explicitly >>> terminate the buffer with a null byte. Detecting truncation is yet >>> another problem. >>>=20 >>> stpecpy(3), described in the new string_copying(7) manual page, is >>> similar to OpenBSD's strlcpy(3)/strlcat(3), but: >>>=20 >>> - It's simpler to implement. >>> - It's faster. >>> - It's simpler to detect truncation. >> Given strlcpy and strlcat are in POSIX next and therefore bar >> some extraordinary event will be in glibc, I think we should >> probably wait until those two land, then see if there's still >> an appetite for stpecpy in glibc. >=20 > I disagree for the following reasons. [snip] Hi Alex, Thanks for your detailed and thoughtful reply. I'll reflect on your = comments here and in the rest of the thread(s) - but there's some intriguing pointers = you've made. I wasn't trying to be dismissive at all so I hope it didn't come across = like that. Thank you again! Best, sam --Apple-Mail=_2A887ADB-5F72-4CDC-AEC0-28B2922C56A2 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iNUEARYKAH0WIQQlpruI3Zt2TGtVQcJzhAn1IN+RkAUCY7BRm18UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0MjVB NkJCODhERDlCNzY0QzZCNTU0MUMyNzM4NDA5RjUyMERGOTE5MAAKCRBzhAn1IN+R kAcWAP9WVn71tWRSHF/uVgGhDXKa0XofEYPayJlCyxZC8FDK5wEAkoKoBVH5vmc9 PdXA79h5jwRFHCLVRyQD1wCJit87qwU= =Q4sq -----END PGP SIGNATURE----- --Apple-Mail=_2A887ADB-5F72-4CDC-AEC0-28B2922C56A2--