From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by sourceware.org (Postfix) with ESMTPS id 29BE23858D38 for ; Wed, 8 Nov 2023 09:51:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 29BE23858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 29BE23858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=139.178.84.217 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699437093; cv=none; b=Rhv6iYkCG9zr6j2mB2vEoJZF19NpmsN2c5M6vKmLToh9t/R6qtDmJMATJzBg7Ua5Kqo+jvMlGfPztWkbxqpRFpKI7Kk+JgbWcGDzVbLWLDHiFrRsQCCOAqAEyIxQKhzDXITKT/0iUvBgpmTm75wQ780LJfGy36xvx33s5dKpNj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699437093; c=relaxed/simple; bh=ROVapZD+UR5aIwgS7ZsFaSdWGmRTyHXP8BxTuMU2Emk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=hX1KMaGxMtjGpQ6STHC6Mi9Y5UAbXYM08s/2RUw5ep0xtnypq9Q7atlj2p9zfrjhKNHyJjGyg/ysyoBpY46KS6Y9Wa6THU5bPjbONkduH5JXq3vD/2W6Vrp0mFAj8goKOnlHqomZuUkv31FoGQbpWHNqOn1mibNyXMrPykIvZyc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B1F6E614BE; Wed, 8 Nov 2023 09:51:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F190C433C8; Wed, 8 Nov 2023 09:51:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699437090; bh=ROVapZD+UR5aIwgS7ZsFaSdWGmRTyHXP8BxTuMU2Emk=; h=Date:From:To:Subject:References:In-Reply-To:From; b=YNwSxs383L4Hcz7jxuX72u0NlsHnqoCuaY6+8QTixksfzHuuTlXEnlCN6c9jMnGnd yeN3VSZdsHEqHZctwla69eUf1iFx+z6CrNp7/7yXR4OAvLyz2G1WQHg/fMkFIeUItz A21qbvx1iVJXBIw43BkwlljRnWcN63eRx/E04yILGmDF2HcptTQ489+KdA4WTCYGBQ uCpUB4/OClqTe6AXcxw4FDjQCuNkRi9e8r+jhd6ty4NnipvJVAEyoCqhHy6Ni6Qq/9 CaPeHuo1xrJQ4YnM5F4SiR7a6tPWhPO0d0S+sJ1AsHytlPAqIPYOAcD26rOIo4V9IX /tjfWyy7sYFnQ== Date: Wed, 8 Nov 2023 10:51:21 +0100 From: Alejandro Colomar To: libc-alpha@sourceware.org, Jonny Grant , linux-man Subject: Re: strncpy clarify result may not be null terminated Message-ID: References: <929865e3-17b4-49c4-8fa9-8383885e9904@jguk.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2g7aQaZPeLWPOG8T" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: --2g7aQaZPeLWPOG8T Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Wed, 8 Nov 2023 10:51:21 +0100 From: Alejandro Colomar To: libc-alpha@sourceware.org, Jonny Grant , linux-man Subject: Re: strncpy clarify result may not be null terminated On Wed, Nov 08, 2023 at 12:18:09AM -0600, Oskari Pirhonen wrote: > On Tue, Nov 07, 2023 at 17:17:29 +0100, Alejandro Colomar wrote: > >=20 > > I would love to find this API useless, and in that case, I'd go further > > and add [[deprecated]] in the synopsis, and write a heavy statement in a > > BUGS section. But I can't do that while it's still a good function in > > some cases (even if those cases are bad design, such as utmp(5)). > >=20 > > On the other hand, utmp(5) has other issues, like Y2038, and AFAIR it's > > being deprecated, so maybe we could consider deprecating strncpy(3). > >=20 > > If I see enough proof that all APIs that require this function are > > deprecated, I'll happily declare the function deprecated as well. > > (in fact I already did some time ago, but then found this use with > > utmp(5), which is why I removed the deprecation; see > > ). > >=20 >=20 > If you ask me, I'd not mark libc functions as deprecated without some > kind of consesnsus from the libc maintainers too. They may not go so far > as to add the `deprecated` attribute in their own headers, at least not > yet at that point in time, but some kind of written "Yes, please don't > use this function" would be nice to have before marking them in the man > pages. Okay, let's ask them. Hi glibc developers, strncpy(3) is useful to write to fixed-width buffers like `struct utmp` and `struct utmpx`. Is there any other libc API that needs strncpy(3)? Of those two APIs (utmp and utmpx) and any other that need strncpy(3), are those deprecated, or is any such API still good for new code? If all APIs that need strncpy(3) are deprecated, I propose recommending against its use in new code. Thanks, Alex >=20 > - Oskari --=20 --2g7aQaZPeLWPOG8T Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmVLWhkACgkQnowa+77/ 2zJl+w//SBaYK7BvEsksDWCKQyCXT9A+NoIkHp6iCj1HGTlIUKvM9g+lKiHhwADj Gzq8bcihxlU0chm6WMqESBshPBXvhNyKu6UgUJJLcOgfAniAhWLABoDROnb0pDgt wAeiCmSv4qUz6dUAKouQqmLj/7Gq3iaw8XSkpsYx4z8AW67RE+VMV69tPcu3xtpp 4na4NXgZSqFLdya7kxNUGmGobVc60YlHBfJqkPScAlwBv7XKbLbwfBolTGokfchu 0R/TKp+K+lpRbL+LVLmXbc2ic48yP/TpKNLOIwvFb/DpImAyLfURSkgnOSBil0hF p79jqbZoSuDdJft1Lg9dVG5Uotd4w3Z+bjQtypRL4PFDW0CJEztZq2JrW3cVIasw HyIo8oJanjMl2dOX5FqKv/lyWB1xQxqE7Q7NLvo4n6K+Dlckup2RwyUQ+MUVWhlU WEAgYNUoTd+Ktjw4u/66418rQxWHT9wqUwENzL3hmq0G8U0wMv3eZC3XMUr9cMOe C72luBxUYOml2m22whrvy8/Ve6gykDaV+MJ1koZV6LNP1hYJ+O5/y2HSAIrUIZLJ 9VGasERBUnSa19cUNBpCOL/tryvGrzAkdqsy86x2K0YEb0QOX7cJNIt79Cs9uA3X +5uqjNGHYIPp2nDyIC/xDYgC7J5/LHrFe3GOUer5AUyJbUsRk5k= =Ipfs -----END PGP SIGNATURE----- --2g7aQaZPeLWPOG8T--