From: Joe Perches <joe@perches.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
Julia Lawall <julia.lawall@lip6.fr>,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
LKML <linux-kernel@vger.kernel.org>,
clang-built-linux@googlegroups.com,
Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: stracpy
Date: Tue, 20 Aug 2019 17:58:27 -0700 [thread overview]
Message-ID: <b77a3752d9b9897b8e65003ad88991b18ee33029.camel@perches.com> (raw)
In-Reply-To: <CAHk-=wg8vLmmwTGhXM51NpSWJW8RFEAKoXxG0Hu_Q9Uwbjj8kw@mail.gmail.com>
On Tue, 2019-08-20 at 17:43 -0700, Linus Torvalds wrote:
> On Tue, Aug 20, 2019 at 5:20 PM Joe Perches <joe@perches.com> wrote:
> > Umm, btw: have you actually looked at stracpy?
>
> Yes, Joe, I have.
>
> What part of "there are now so many of them that no human being can
> keep track of them" didn't you see as a problem?
Well, the actual post-conversion uses to stracpy make the old ones
(strcpy/strlcpy/strncpy) exceptional uses that can be analyzed
quite a bit more easily.
btw: I really don't care what any convenience macro is named.
Most all of the strlcpy and strscpy uses actually _do_ copy to
a char array and strscpy is a simple interface that is somewhat
frequently misused.
> How many broken string functions are we going to do, adding yet
> another one when you notice that the _last_ one wasn't great?
>
> We never seem to remove the broken ones. We just add yet another one,
> and have a never-ending jumble of random letters.
<shrug> Intermediate problems.
> I would seriously suggest doing something like
> and
> copy_string( dst, dstsize, src, srcsize, FLAGS );
>
> where FLAGS migth be "pad" or whatever. Make it return the size of the
> resulting string, because while it can be convenient to pass 'dst" on,
> it's not useful.
That's simply not convenient for pointers.
Auditing the kernel for those unsized uses is a
large scope problem. Even anything that uses
PAGE_SIZE sized allocations does sprintf
instead of snprintf. Any show_<foo> for instance.
> And then maybe just add the helper macro that turns an array into a
> "pointer, size" combination, rather than yet another letter jumble.
Good luck with that when an unsized char pointer is the thing
passed to a function.
There are _way_ too many of those already in the kernel.
Simple strcpy is already used > 2000 times.
next prev parent reply other threads:[~2019-08-21 0:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <c0005a09c89c20093ac699c97e7420331ec46b01.camel@perches.com>
[not found] ` <9c7a79b4d21aea52464d00c8fa4e4b92638560b6.camel@perches.com>
[not found] ` <CAHk-=wiL7jqYNfYrNikgBw3byY+Zn37-8D8yR=WUu0x=_2BpZA@mail.gmail.com>
[not found] ` <6a5f470c1375289908c37632572c4aa60d6486fa.camel@perches.com>
2019-08-10 20:33 ` [PATCH] Makefile: Convert -Wimplicit-fallthrough=3 to just -Wimplicit-fallthrough for clang Joe Perches
2019-08-16 19:58 ` rfc: treewide scripted patch mechanism? (was: Re: [PATCH] Makefile: Convert -Wimplicit-fallthrough=3 to just -Wimplicit-fallthrough for clang) Joe Perches
2019-08-19 23:24 ` rfc: treewide scripted patch mechanism? (was: Re: [PATCH] Makefile: Convert -Wimplicit-fallthrough=3 to just -Wimplicit-fallthrough for clang)QUILT Stephen Rothwell
2019-08-20 0:08 ` Joe Perches
2019-08-20 23:28 ` Linus Torvalds
2019-08-20 23:37 ` Joe Perches
2019-08-21 0:39 ` Linus Torvalds
2019-08-26 8:58 ` Geert Uytterhoeven
2019-08-21 0:20 ` Joe Perches
2019-08-21 0:43 ` Linus Torvalds
2019-08-21 0:58 ` Joe Perches [this message]
2019-08-21 4:01 ` Willy Tarreau
2019-08-21 0:33 ` Stephen Rothwell
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=b77a3752d9b9897b8e65003ad88991b18ee33029.camel@perches.com \
--to=joe@perches.com \
--cc=clang-built-linux@googlegroups.com \
--cc=gustavo@embeddedor.com \
--cc=julia.lawall@lip6.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
--cc=torvalds@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).