input: synaptics-rmi4 - use snprintf instead of sprintf in rmi_i2c.c
Subsystems (2)
PATCH 1/1 input: synaptics-rmi4 - use snprintf instead of sprintf in rmi_i2c.c
This is a trivial change to use snprintf rather than sprintf while building the diagnostic output buffer.
Signed-off-by Christopher Heiny <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Benjamin Tissoires <[email protected]>
---
drivers/input/rmi4/rmi_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/rmi4/rmi_i2c.c +1 -1
@@ -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; }
Dmitry Torokhov
maintainerQuoted 17 lines · Christopher Heiny
This is a trivial change to use snprintf rather than sprintf while building the diagnostic output buffer.
Signed-off-by Christopher Heiny <[email protected]>Cc Dmitry Torokhov <[email protected]>Cc Benjamin Tissoires <[email protected]>---
drivers/input/rmi4/rmi_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/input/rmi4/rmi_i2c.c +0
-0
drivers/input/rmi4/rmi_i2c.c static int copy_to_debug_buf(struct device *dev, struct rmi_i2c_data *data, · line 163
Quoted 8 lines
drivers/input/rmi4/rmi_i2c.c +1
-1@@ -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.
Signature · 1 line
Dmitry