linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@nxp.com>
To: "sboyd@kernel.org" <sboyd@kernel.org>,
	"linux@armlinux.org.uk" <linux@armlinux.org.uk>
Cc: dl-linux-imx <linux-imx@nxp.com>,
	"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Alice Guo <alice.guo@nxp.com>, Peng Fan <peng.fan@nxp.com>,
	Kees Cook <keescook@chromium.org>
Subject: [PATCH] clk: clkdev: Replace strlcpy with strscpy
Date: Fri, 15 Nov 2019 10:17:53 +0000	[thread overview]
Message-ID: <1573812819-5030-1-git-send-email-peng.fan@nxp.com> (raw)

From: Peng Fan <peng.fan@nxp.com>

The implementation of strscpy() is more robust and safer.

The strscpy was introduced to fix some API problems around strlcpy.
strscpy is preferred to strlcpy() since the API doesn't require
reading memory from the src string beyond the specified "count" bytes,
and since the return value is easier to error-check than strlcpy()'s.
In addition, the implementation is robust to the string changing out
from underneath it, unlike the current strlcpy() implementation.

Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/clk/clkdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 0f2e3fcf0f19..ee56109bc0b4 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -165,7 +165,7 @@ vclkdev_alloc(struct clk_hw *hw, const char *con_id, const char *dev_fmt,
 
 	cla->cl.clk_hw = hw;
 	if (con_id) {
-		strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
+		strscpy(cla->con_id, con_id, sizeof(cla->con_id));
 		cla->cl.con_id = cla->con_id;
 	}
 
-- 
2.16.4


             reply	other threads:[~2019-11-15 10:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15 10:17 Peng Fan [this message]
2019-11-15 17:00 ` [PATCH] clk: clkdev: Replace strlcpy with strscpy Kees Cook

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=1573812819-5030-1-git-send-email-peng.fan@nxp.com \
    --to=peng.fan@nxp.com \
    --cc=alice.guo@nxp.com \
    --cc=keescook@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=sboyd@kernel.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).