Re: [PATCH v2 1/4] man/man3/str*.3: NAME: Explain the names
Alejandro Colomar <[email protected]> Mon, 27 Jul 2026 09:51:39 +0200
| Newsgroups | org.kernel.vger.linux-man |
|---|---|
| Message-ID | <amcMzmP4CF9RkbDk@devuan> |
Hi Serge, On 2026-07-26T21:39:34-0500, Serge E. Hallyn wrote: > > [...] > > > > @@ -5,10 +5,7 @@ > > > > .\" > > > > .TH strncat 3 (date) "Linux man-pages (unreleased)" > > > > .SH NAME > > > > -strncat > > > > -\- > > > > -append non-null bytes from a source array to a string, > > > > -and null-terminate the result > > > > +strncat \- nonstring catenate > > > > > > why nonstring? The source string doesn't *have* to be a string, > > > but can be, right? > > > > Yup, it can be a string, although it would be useless (if you want > > a string, you can use strcat(3)). > > If the destination is 10 bytes long and has a 5 character string now, > and the source is a valid string that's 15 characters long, it's still > not safe to use strcat. It's not safe to use strncat(3) either. At least for my high standards. It's full of off-by-one opportunities, and other opportunities for bugs, which will result in buffer overflows. :) One should write and use strtcat(). Here's a patch set for doing that in shadow, FWIW: <https://github.com/shadow-maint/shadow/pull/1334>. That patch set is very small, so if you merge it already, I'd appreciate it. Have a lovely day! Alex -- <https://www.alejandro-colomar.es>
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmpnDgUACgkQ64mZXMKQ wqkdexAAn4iHH2KQaiydMu7bHSYGeqfRBOYhMq38YanKbGy5tO4HStjz4FivG9C7 CwqOTuKuEtaBzw9yqlghPA8NeUHSqmlfzmCoahsTSm77P+PTjNyeV6hr478ACMZg 4SRYHf2w+KPIrtGt3aTV1/euw4li4pcZCQh9LOPjfirpTi26/vR1Wwu9C+Qaw/Ir s1TwnP6p9Tj9COeU75CnHM3FHt0tBhNfBZAACO32N1nH8X3sxh66xiVODTCtCx7e Js3dz6NEfzq+cl30U5GQgsOLWoHElE67bcjcosncfomDi8BUZXGrmcHh5N5Z6wPp YD3MyRpAW+5pSHMOhlWyUFZZ6YhUHxEyti8SROoHTG/vTmxmzex4l/zXWVKJGkj2 vHeGe9Ro2Hvj7YJzPWYAc1QpiEpRLQR3KsqO2kcFTal2P0ElfKfucljpQ2bHf5VF 6hlA63rTAPxyEDQ5MKreBZK5nvrFmXq8ZSmUa5vDClBET2jXLVmLANFyP59c9cAZ 53Csn7aW7Oj+mu9f3RFKl19hn6YxzZ9L1o6iPrBNAyiwiusFyPcgYoNZ25daRDww nRaWn8nRsASXZTCr2nVyXJ9o8prpL0OoxCTY/ej1W4lPxWr3nLtrzInXwAMI9kM7 ObngQemcTTSCTlVny5ZIdR0MjzrjpAENxUFkdJe7E9zEF9NG924= =nLup -----END PGP SIGNATURE-----