From: Willy Tarreau <w@1wt.eu>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: Xiongfeng Wang <wangxiongfeng2@huawei.com>,
Dan <dan.carpenter@oracle.com>, Arnd Bergmann <arnd@arndb.de>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2] auxdisplay: use correct string length
Date: Mon, 12 Feb 2018 18:11:37 +0100 [thread overview]
Message-ID: <20180212171137.GA31601@1wt.eu> (raw)
In-Reply-To: <CANiq72=AeytaT5KBtujTBUkfbNTFFxMPAeToqzmZJOr790R6yw@mail.gmail.com>
On Mon, Feb 12, 2018 at 01:53:57PM +0100, Miguel Ojeda wrote:
> > diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c
> > index ea7869c..d288900 100644
> > --- a/drivers/auxdisplay/panel.c
> > +++ b/drivers/auxdisplay/panel.c
> > @@ -1506,10 +1506,10 @@ static struct logical_input *panel_bind_key(const char *name, const char *press,
> > key->rise_time = 1;
> > key->fall_time = 1;
> >
> > - strncpy(key->u.kbd.press_str, press, sizeof(key->u.kbd.press_str));
> > - strncpy(key->u.kbd.repeat_str, repeat, sizeof(key->u.kbd.repeat_str));
> > + strncpy(key->u.kbd.press_str, press, sizeof(key->u.kbd.press_str) - 1);
> > + strncpy(key->u.kbd.repeat_str, repeat, sizeof(key->u.kbd.repeat_str) - 1);
> > strncpy(key->u.kbd.release_str, release,
> > - sizeof(key->u.kbd.release_str));
> > + sizeof(key->u.kbd.release_str) - 1);
>
> Are you sure about this patch? `kbd` says "strings can be non null-terminated".
>
> Willy, maybe those should just be memcpy()s? (unless the remaining
> bytes, if any, must be 0).
For me this seems to be the result of yet another very stupid gcc warning
trying to dissuade us from using well defined fonctions... it's unimaginable
how gcc warnings have become stupid and irrelevant since its developers
stopped using C to write it :-(
If you want to work around this wrong warning, probably that increasing the
destination storage size by one and adding -1 to strncpy() would shut it up
but that really becomes quite annoying to have to modify code and storage
just to shut down a dumbass compiler trying to be smart.
Willy
next prev parent reply other threads:[~2018-02-12 17:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-16 9:38 [PATCH V2] auxdisplay: use correct string length Xiongfeng Wang
2018-02-12 12:53 ` Miguel Ojeda
2018-02-12 17:11 ` Willy Tarreau [this message]
2018-02-12 20:42 ` Miguel Ojeda
2018-02-13 1:19 ` Xiongfeng Wang
2018-02-13 7:23 ` Willy Tarreau
2018-02-13 8:28 ` Arnd Bergmann
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=20180212171137.GA31601@1wt.eu \
--to=w@1wt.eu \
--cc=arnd@arndb.de \
--cc=dan.carpenter@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=wangxiongfeng2@huawei.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