All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: sun6-p2wi: fix call to snprintf
       [not found] <CAGXu5jLi5NXNsbUAn=XndDb2JSTxiVhMWbiMxtDsUOqZZhxf2A@mail.gmail.com>
@ 2014-06-13  7:20     ` Boris BREZILLON
  0 siblings, 0 replies; 6+ messages in thread
From: Boris BREZILLON @ 2014-06-13  7:20 UTC (permalink / raw)
  To: Kees Cook, Wolfram Sang
  Cc: Fengguang Wu, Maxime Ripard, Shuge,
	kevin-0TFLnhJekD6UEPyfVivIlAC/G2K4zDHf,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Boris BREZILLON

Fixes possible issue in case pdev name contains formatting characters.

Signed-off-by: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Reported-by: Kees Cook <keescook-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
---
 drivers/i2c/busses/i2c-sun6i-p2wi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c
index 5d2d678..63d1b2d 100644
--- a/drivers/i2c/busses/i2c-sun6i-p2wi.c
+++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c
@@ -237,7 +237,8 @@ static int p2wi_probe(struct platform_device *pdev)
 	if (IS_ERR(p2wi->regs))
 		return PTR_ERR(p2wi->regs);
 
-	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), pdev->name);
+	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), "%s",
+		 pdev->name);
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(dev, "failed to retrieve irq: %d\n", irq);
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] i2c: sun6-p2wi: fix call to snprintf
@ 2014-06-13  7:20     ` Boris BREZILLON
  0 siblings, 0 replies; 6+ messages in thread
From: Boris BREZILLON @ 2014-06-13  7:20 UTC (permalink / raw)
  To: linux-arm-kernel

Fixes possible issue in case pdev name contains formatting characters.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
Reported-by: Kees Cook <keescook@google.com>
---
 drivers/i2c/busses/i2c-sun6i-p2wi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c
index 5d2d678..63d1b2d 100644
--- a/drivers/i2c/busses/i2c-sun6i-p2wi.c
+++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c
@@ -237,7 +237,8 @@ static int p2wi_probe(struct platform_device *pdev)
 	if (IS_ERR(p2wi->regs))
 		return PTR_ERR(p2wi->regs);
 
-	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), pdev->name);
+	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), "%s",
+		 pdev->name);
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(dev, "failed to retrieve irq: %d\n", irq);
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: sun6-p2wi: fix call to snprintf
  2014-06-13  7:20     ` Boris BREZILLON
@ 2014-06-13  9:57         ` Russell King - ARM Linux
  -1 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux @ 2014-06-13  9:57 UTC (permalink / raw)
  To: Boris BREZILLON
  Cc: Kees Cook, Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Shuge,
	Maxime Ripard, Fengguang Wu,
	kevin-0TFLnhJekD6UEPyfVivIlAC/G2K4zDHf,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Fri, Jun 13, 2014 at 09:20:02AM +0200, Boris BREZILLON wrote:
> -	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), pdev->name);
> +	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), "%s",
> +		 pdev->name);

Isn't this just a complicated way to express:

	strlcpy(p2wi->adapter.name, pdev->name, sizeof(p2wi->adapter.name));

?

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] i2c: sun6-p2wi: fix call to snprintf
@ 2014-06-13  9:57         ` Russell King - ARM Linux
  0 siblings, 0 replies; 6+ messages in thread
From: Russell King - ARM Linux @ 2014-06-13  9:57 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 13, 2014 at 09:20:02AM +0200, Boris BREZILLON wrote:
> -	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), pdev->name);
> +	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), "%s",
> +		 pdev->name);

Isn't this just a complicated way to express:

	strlcpy(p2wi->adapter.name, pdev->name, sizeof(p2wi->adapter.name));

?

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: sun6-p2wi: fix call to snprintf
  2014-06-13  9:57         ` Russell King - ARM Linux
@ 2014-06-13 10:09             ` Boris BREZILLON
  -1 siblings, 0 replies; 6+ messages in thread
From: Boris BREZILLON @ 2014-06-13 10:09 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Kees Cook, Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Shuge,
	Maxime Ripard, Fengguang Wu,
	kevin-0TFLnhJekD6UEPyfVivIlAC/G2K4zDHf,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r


On 13/06/2014 11:57, Russell King - ARM Linux wrote:
> On Fri, Jun 13, 2014 at 09:20:02AM +0200, Boris BREZILLON wrote:
>> -	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), pdev->name);
>> +	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), "%s",
>> +		 pdev->name);
> Isn't this just a complicated way to express:
>
> 	strlcpy(p2wi->adapter.name, pdev->name, sizeof(p2wi->adapter.name));
>
> ?

Yes it is. I'll make use of strlcpy instead.

Thanks,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] i2c: sun6-p2wi: fix call to snprintf
@ 2014-06-13 10:09             ` Boris BREZILLON
  0 siblings, 0 replies; 6+ messages in thread
From: Boris BREZILLON @ 2014-06-13 10:09 UTC (permalink / raw)
  To: linux-arm-kernel


On 13/06/2014 11:57, Russell King - ARM Linux wrote:
> On Fri, Jun 13, 2014 at 09:20:02AM +0200, Boris BREZILLON wrote:
>> -	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), pdev->name);
>> +	snprintf(p2wi->adapter.name, sizeof(p2wi->adapter.name), "%s",
>> +		 pdev->name);
> Isn't this just a complicated way to express:
>
> 	strlcpy(p2wi->adapter.name, pdev->name, sizeof(p2wi->adapter.name));
>
> ?

Yes it is. I'll make use of strlcpy instead.

Thanks,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-13 10:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAGXu5jLi5NXNsbUAn=XndDb2JSTxiVhMWbiMxtDsUOqZZhxf2A@mail.gmail.com>
     [not found] ` <CAGXu5jLi5NXNsbUAn=XndDb2JSTxiVhMWbiMxtDsUOqZZhxf2A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-06-13  7:20   ` [PATCH] i2c: sun6-p2wi: fix call to snprintf Boris BREZILLON
2014-06-13  7:20     ` Boris BREZILLON
     [not found]     ` <1402644002-2591-1-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-06-13  9:57       ` Russell King - ARM Linux
2014-06-13  9:57         ` Russell King - ARM Linux
     [not found]         ` <20140613095714.GP23430-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-06-13 10:09           ` Boris BREZILLON
2014-06-13 10:09             ` Boris BREZILLON

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.