* [PATCH] input: synaptics-rmi4 - use snprintf instead of sprintf in rmi_i2c.c
@ 2014-01-08 21:37 Christopher Heiny
2014-01-08 22:44 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Christopher Heiny @ 2014-01-08 21:37 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Linux Input, Christopher Heiny, Andrew Duggan, Vincent Huang,
Vivian Ly, Daniel Rosenberg, Jean Delvare, Joerie de Gram,
Linus Walleij, Benjamin Tissoires
This is a trivial change to use snprintf rather than sprintf while building
the diagnostic output buffer.
Signed-off-by: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
drivers/input/rmi4/rmi_i2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
index b33074c..43b0e53 100644
--- a/drivers/input/rmi4/rmi_i2c.c
+++ b/drivers/input/rmi4/rmi_i2c.c
@@ -157,7 +157,7 @@ static int copy_to_debug_buf(struct device *dev, struct rmi_i2c_data *data,
temp = data->debug_buf;
for (i = 0; i < len; i++) {
- n = sprintf(temp, " %02x", buf[i]);
+ n = snprintf(temp, 3, " %02x", buf[i]);
temp += n;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] input: synaptics-rmi4 - use snprintf instead of sprintf in rmi_i2c.c
2014-01-08 21:37 [PATCH] input: synaptics-rmi4 - use snprintf instead of sprintf in rmi_i2c.c Christopher Heiny
@ 2014-01-08 22:44 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2014-01-08 22:44 UTC (permalink / raw)
To: Christopher Heiny
Cc: Linux Input, Andrew Duggan, Vincent Huang, Vivian Ly,
Daniel Rosenberg, Jean Delvare, Joerie de Gram, Linus Walleij,
Benjamin Tissoires
On Wed, Jan 08, 2014 at 01:37:55PM -0800, Christopher Heiny wrote:
> This is a trivial change to use snprintf rather than sprintf while building
> the diagnostic output buffer.
>
> Signed-off-by: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>
> ---
>
> drivers/input/rmi4/rmi_i2c.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
> index b33074c..43b0e53 100644
> --- a/drivers/input/rmi4/rmi_i2c.c
> +++ b/drivers/input/rmi4/rmi_i2c.c
> @@ -157,7 +157,7 @@ static int copy_to_debug_buf(struct device *dev, struct rmi_i2c_data *data,
> temp = data->debug_buf;
>
> for (i = 0; i < len; i++) {
> - n = sprintf(temp, " %02x", buf[i]);
> + n = snprintf(temp, 3, " %02x", buf[i]);
> temp += n;
> }
>
I do not think it is right, as if there is truncation you'd move too
far. In any case please replace the while loop with:
snprintf(data->debug_buf, data->debug_buf_size, "%*ph", len, buf);
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-08 22:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-08 21:37 [PATCH] input: synaptics-rmi4 - use snprintf instead of sprintf in rmi_i2c.c Christopher Heiny
2014-01-08 22:44 ` Dmitry Torokhov
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).