From: Xiongfeng Wang <wangxiongfeng2@huawei.com>
To: <miguel.ojeda.sandonis@gmail.com>
Cc: <linux-kernel@vger.kernel.org>, <arnd@arndb.de>,
<wangxiongfeng2@huawei.com>
Subject: [PATCH] auxdisplay: use correct string length
Date: Mon, 8 Jan 2018 20:08:05 +0800 [thread overview]
Message-ID: <1515413285-40933-1-git-send-email-wangxiongfeng2@huawei.com> (raw)
From: Xiongfeng Wang <xiongfeng.wang@linaro.org>
gcc-8 reports
drivers/auxdisplay/panel.c: In function 'panel_attach':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified
bound 12 equals destination size [-Wstringop-truncation]
We need one less byte or call strlcpy() to make it a nul-terminated
string.
Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org>
---
drivers/auxdisplay/panel.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c
index ea7869c..f8344e4 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));
list_add(&key->list, &logical_inputs);
return key;
}
--
1.8.3.1
next reply other threads:[~2018-01-08 12:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-08 12:08 Xiongfeng Wang [this message]
2018-01-16 8:40 ` Dan Carpenter
2018-01-16 9:22 ` Xiongfeng Wang
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=1515413285-40933-1-git-send-email-wangxiongfeng2@huawei.com \
--to=wangxiongfeng2@huawei.com \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=miguel.ojeda.sandonis@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®