All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx@kernel.org>
To: "Serge E. Hallyn" <serge@hallyn.com>
Cc: linux-man@vger.kernel.org, Mark Harris <mark.hsj@gmail.com>,
	 "G. Branden Robinson" <g.branden.robinson@gmail.com>,
	Douglas McIlroy <douglas.mcilroy@dartmouth.edu>
Subject: Re: [PATCH v2 1/4] man/man3/str*.3: NAME: Explain the names
Date: Mon, 27 Jul 2026 09:51:39 +0200	[thread overview]
Message-ID: <amcMzmP4CF9RkbDk@devuan> (raw)
In-Reply-To: <ambE5rIikTuHudR4@mail.hallyn.com>

[-- Attachment #1: Type: text/plain, Size: 1265 bytes --]

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>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-07-27  7:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02 12:33 [PATCH v1 1/2] man/man3/str*.3: NAME: Explain the names Alejandro Colomar
2026-07-02 12:33 ` [PATCH v1 2/2] man/man3/strpbrk.3: BUGS: Clarify the NAME Alejandro Colomar
2026-07-03  5:03 ` [PATCH v1 1/2] man/man3/str*.3: NAME: Explain the names Mark Harris
2026-07-03 11:16   ` Alejandro Colomar
2026-07-08 15:09 ` [PATCH v2 0/4] str*.3, mem*.3: " Alejandro Colomar
2026-07-08 15:09   ` [PATCH v2 1/4] man/man3/str*.3: " Alejandro Colomar
2026-07-24 18:52     ` sergeh
2026-07-25 22:09       ` Alejandro Colomar
2026-07-26 23:14         ` alx-0096r1 - string (and nonstring) copying Alejandro Colomar
2026-07-27  2:39         ` [PATCH v2 1/4] man/man3/str*.3: NAME: Explain the names Serge E. Hallyn
2026-07-27  7:51           ` Alejandro Colomar [this message]
2026-07-08 15:09   ` [PATCH v2 2/4] man/man3/strpbrk.3: BUGS: Clarify the NAME Alejandro Colomar
2026-07-24 18:53     ` sergeh
2026-07-25 22:10       ` Alejandro Colomar
2026-07-08 15:09   ` [PATCH v2 3/4] man/man3/mem*.3: NAME: Explain the names Alejandro Colomar
2026-07-24 18:55     ` sergeh
2026-07-08 15:09   ` [PATCH v2 4/4] man/man3/[b]string.3: Rewrite and merge Alejandro Colomar
2026-07-25 23:49 ` [PATCH v3 0/4] str*.3, mem*.3: NAME: Explain the names Alejandro Colomar
2026-07-25 23:49   ` [PATCH v3 1/4] man/man3/str*.3: " Alejandro Colomar
2026-07-25 23:50   ` [PATCH v3 2/4] man/man3/strpbrk.3: BUGS: Clarify the NAME Alejandro Colomar
2026-07-25 23:50   ` [PATCH v3 3/4] man/man3/mem*.3: NAME: Explain the names Alejandro Colomar
2026-07-25 23:50   ` [PATCH v3 4/4] man/man3/[b]string.3: Rewrite and merge Alejandro Colomar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=amcMzmP4CF9RkbDk@devuan \
    --to=alx@kernel.org \
    --cc=douglas.mcilroy@dartmouth.edu \
    --cc=g.branden.robinson@gmail.com \
    --cc=linux-man@vger.kernel.org \
    --cc=mark.hsj@gmail.com \
    --cc=serge@hallyn.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.