i2c: sun6-p2wi: fix call to snprintf
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): CAGXu5jLi5NXNsbUAn=XndDb2JSTxiVhMWbiMxtDsUOqZZhxf2A@mail.gmail.com
PATCH 1/1 i2c: sun6-p2wi: fix call to snprintf
Fixes possible issue in case pdev name contains formatting characters.
Signed-off-by Boris BREZILLON <[email protected]>
Reported-by Kees Cook <[email protected]>
--- drivers/i2c/busses/i2c-sun6i-p2wi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-sun6i-p2wi.c +2 -1
@@ -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);
Signature · 1 line
1.8.3.2
PATCH 1/1 i2c: sun6-p2wi: fix call to snprintf
drivers/i2c/busses/i2c-sun6i-p2wi.c static int p2wi_probe(struct platform_device *pdev) · line 241
Quoted 3 lines · Boris BREZILLON
drivers/i2c/busses/i2c-sun6i-p2wi.c +2
-1-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));
?
Signature · 2 lines
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly improving, and getting towards what was expected from it.
PATCH 1/1 i2c: sun6-p2wi: fix call to snprintf
Quoted 9 lines · Russell King - ARM Linux
drivers/i2c/busses/i2c-sun6i-p2wi.c static int p2wi_probe(struct platform_device *pdev) · line 241
Quoted 3 lines · Boris BREZILLON
drivers/i2c/busses/i2c-sun6i-p2wi.c +2
-1-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
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com