From: David Laight <david.laight.linux@gmail.com>
To: Alejandro Colomar <alx+linux-hardening@kernel.org>
Cc: Mariia Nikitash <nikitash.mariiaw@gmail.com>,
dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
kees@kernel.org, justinstitt@google.com, morbo@google.com
Subject: Re: [PATCH] Input: mouse: vsxxxaa: Replace strlcat() with strscpy()
Date: Thu, 5 Nov 2026 20:53:21 +0000 [thread overview]
Message-ID: <20261105205321.7b303231@pumpkin> (raw)
In-Reply-To: <auxrRmyg50gvP1HE@devuan>
On Thu, 5 Nov 2026 12:49:59 +0100
Alejandro Colomar <alx+linux-hardening@kernel.org> wrote:
> > Personally I think that while there are issues with strlcat()
> > (mostly to do with its return value), and that there are often
> > much better (and faster - so sprintf is out) ways of getting
> > the same result, the deprecation really needs to propose a
> > sensible alternative (not inlined strlen() + strscpy()).
>
> One alternative would be to add strscat(), with the obvious internal
> strlen(3). This would be a drop-in replacement, and wouldn't have the
> issues of strlcat(3) --mainly, the DoS vulnerability which is
> consequence of the return value, and also the more difficult error
> handling of doing '>=sizeof(...)' than '<0'--.
I've had thoughts of a more general function - but I've not tried to
write it.
int str_append(char *dest, size_t dest_sz, size_t dest_off, const char *src, size_t src_max_len);
Where dest_sz is usually sizeof(*dest) and the header can substitute that for
a constant zero.
dest_off would similarly default to strlen(dest), if -ve the function would
return that value immediately.
src_max_len would be used for an effective strnlen(src, src_max_len).
The idea would be that calls like:
char tgt[100];
len = str_append(tgt, 0, strscpy(tgt, src_1), src_2, 0);
would append src_1 and src_2 in tgt returning -ve on overflow.
(Further chaining would then work.)
But, as I said, I've not tried to write it or see what it would look like in use.
David
next prev parent reply other threads:[~2026-11-05 20:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 6:23 Mariia Nikitash
2026-11-04 11:21 ` Alejandro Colomar
2026-11-04 16:33 ` Shihuang Liu
2026-11-05 11:28 ` David Laight
2026-11-05 11:49 ` Alejandro Colomar
2026-11-05 20:53 ` David Laight [this message]
2026-11-05 21:39 ` 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=20261105205321.7b303231@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=alx+linux-hardening@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=justinstitt@google.com \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=morbo@google.com \
--cc=nikitash.mariiaw@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®