From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id D65D53858D28 for ; Thu, 6 Apr 2023 22:15:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D65D53858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-x430.google.com with SMTP id r29so40860629wra.13 for ; Thu, 06 Apr 2023 15:15:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680819356; x=1683411356; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=VW4KhWGQeexx1FWSkIR6dRsnYi3quNrcNZRXyu9KTgA=; b=CIvewe09zrg+aeJWQEdJ6uc5n1SxneLePtAPeVUgyHO2dmSzfDg+KEgVd8AMVsNq7F tDfA+B2fVqXCot1nOgXoUUzOL0cr3DRbUjA80fWhAF4UabI39VVRvzzhB/TIljikfJTh gV5Lw1mwPBoocyvUi4f7YQdnXbQBCqjpcUGbpulABctn7aJPYR8v9PYVt51Qfyzpqwny yqu+/+UlFLtodCiWt9X0bLiMJybYk3O3lkszVAsP55FxmQ2wf6V0GIlntgSH1n/FAO9O L6msT9jmWgSkVs7GK3A4Q5oe5U+8LdcWKpLp9D+qMTnRjXrnWRQaj4YoniTeN+VCQTiA 0Wcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680819356; x=1683411356; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=VW4KhWGQeexx1FWSkIR6dRsnYi3quNrcNZRXyu9KTgA=; b=MLHjWxNrh4ErV/Vdcy7zARyXi9fCBke/GBsQgVn53JpS9j6LTkHAJ7ZJRvSXM2wDsb oQTglpsl5QjzNJziPnU0bM3ZgdBJFuGrFednY9JjyBVzoFlIbn3j4VV4VgfXElH5AKJG 9UbDE9HsvVLVdwP3fk9ezqEvqe9OlA/pCYvIr5giyBMLJ+cQ/F/y8vgewbeoTroz9mqb GzaWNTXNp4jQSy8R56sglnJQRpEt5qfKh8oh2+FmClFFOxv+gvHjRQv/+BHvIOtXICqN AekObrASXzxEcQduTqMW+AH5atD2JoeFT2pWQzVeRNVmh8vh6gSIfIi7jLlnFQIGa1+z 8rQQ== X-Gm-Message-State: AAQBX9ez4Yz/hxdF+aCokYOQoxOGe/e1UhQ2RCnacAjzW89YoBJrYYhR g2qCE7891vfiD7kNAHY9qRsdlwC180s= X-Google-Smtp-Source: AKy350Y+jcuh63HatYpAFaf/vZUx8DiZ9zFo2lu8b1WiZsxzb8ptnQTZul3INfwHRGWULbvF95Xu3A== X-Received: by 2002:a5d:4b83:0:b0:2ee:d93d:1fc2 with SMTP id b3-20020a5d4b83000000b002eed93d1fc2mr2408412wrt.33.1680819355878; Thu, 06 Apr 2023 15:15:55 -0700 (PDT) Received: from [192.168.0.160] ([170.253.51.134]) by smtp.gmail.com with ESMTPSA id y9-20020adffa49000000b002c592535839sm2844192wrr.17.2023.04.06.15.15.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Apr 2023 15:15:55 -0700 (PDT) Message-ID: <39634c36-975a-b065-24db-2c23cbbb8754@gmail.com> Date: Fri, 7 Apr 2023 00:15:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH 1/2] Implement strlcpy and strlcat [BZ #178] Content-Language: en-US To: Florian Weimer , Alejandro Colomar via Libc-alpha References: <8513afd6-e276-05d5-bc4c-0722de71e0af@gmail.com> <87fs9cn171.fsf@mid.deneb.enyo.de> From: Alejandro Colomar In-Reply-To: <87fs9cn171.fsf@mid.deneb.enyo.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------r9Qt6za0Nk3QlLdqh8nM3PFl" X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------r9Qt6za0Nk3QlLdqh8nM3PFl Content-Type: multipart/mixed; boundary="------------8YGYogjVoMj4qv9jgJoRebkl"; protected-headers="v1" From: Alejandro Colomar To: Florian Weimer , Alejandro Colomar via Libc-alpha Message-ID: <39634c36-975a-b065-24db-2c23cbbb8754@gmail.com> Subject: Re: [PATCH 1/2] Implement strlcpy and strlcat [BZ #178] References: <8513afd6-e276-05d5-bc4c-0722de71e0af@gmail.com> <87fs9cn171.fsf@mid.deneb.enyo.de> In-Reply-To: <87fs9cn171.fsf@mid.deneb.enyo.de> --------------8YGYogjVoMj4qv9jgJoRebkl Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Florian, On 4/6/23 23:35, Florian Weimer wrote: [...] >=20 > OpenBSD alludes to this as well: >=20 > | strlcat() appends string src to the end of dst. It will append at > | most dstsize - strlen(dst) - 1 characters. It will then > | NUL-terminate, unless dstsize is 0 or the original dst string was > | longer than dstsize (in practice this should not happen as it means > | that either dstsize is incorrect or that dst is not a proper > | string). Hmm, that text replaced the one I quoted (which has been kept in libbsd's page), in this commit: commit 5df0f979487d1950d0e8885be683158e55ff4ae3 Author: deraadt Date: Mon Apr 2 17:33:11 2012 +0000 simplify the strlcpy/strlcat manual page substantially. do less explaining of "what a C string is", and make it more clear that these= functiosn BEHAVE EXACTLY LIKE snprintf with "%s"! (anyone who wants to write a 'strlcpy considered harmful' paper should probably write a= 'strlcpy and snprintf considered harmful' paper instead). =20 note to those from other projects reading this commit message: It wou= ld be very good if this new manual was picked up in your project. =20 ok jmc millert krw >=20 > >=20 > So I think we should be calling strnlen here. If we call strlen > instead, we'd have to bound the result. Hmm, it depends on what we decide to do with the conditional right after the strnlen(3) call. Either we remove the conditional, or transform strnlen(3) to strlen(3), but not both. I guess strnlen(3) is more readable, since it's just one line. Anyway, as I said, I would just burn it all and make this function be a two-liner. :) Cheers, Alex >=20 > Thanks, > Florian --=20 GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5 --------------8YGYogjVoMj4qv9jgJoRebkl-- --------------r9Qt6za0Nk3QlLdqh8nM3PFl Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmQvRJQACgkQnowa+77/ 2zIBXg/+JfXHW4TvpyqyUOGWBJIe45VwPdXkjWahscIlYDh0lE2i0tNEhIx460PC CnvvievrjIf+Gvqu5TWGs2DoeN7OIzK0xuLxZPoPqiJl2qTTgkv/dwzJIkU0f4Xs C+ps/kd7BIyM7MKu7Yp4YwYEBXEfSs7RXs4Mj8cowaKsF70dgD3EB4u8b6PmmZsa /6duSK9+8ottGuvqWuBPJ+sJFGZTdKPjMVEcp9AwGHLKGfi0BLQSi1GMO0eo7Rau YQBvbzPCLvDliAYzJ/c1nKXX+vNbDpmgqeevmSyry31HRrkq+BHJ0uOwV9hArSnX ldRo+0QtSKn0bLIpkseOtQGX2QZ6TT2bozIQFXtiLM8lmQDwgSrmKPbZN9exGLWv Oyw5pDTZ62CDESjX0A4pE4VpY1YLeG23pDUqW4NtXbBUs5UTuQTu3SHq2FcazuXW xHkvgf9Nvq9Yvcab8QPOG9EES5MMIS5Es6A7Dk0uY0fOOj4PFdNYVwwtr6/X/b/+ nnu0Ju7aQwhNMD8Zk36fLz0B3BCvn7ujVTxbf0BWinHyK04o8pMcPiU96oPCW/ct i0oC5Aczg0uqxzlEr03PzwrFzdijZRv341JkbXHwS4Ie5UhIHUPlrePR3Cftaqzj 0oo6JsJnRDu+uIiLXTbE3UDyyelw6B6u5jdEYaCeq1CuvnumaIo= =nm5U -----END PGP SIGNATURE----- --------------r9Qt6za0Nk3QlLdqh8nM3PFl--