From: Shihuang Liu <shlomojune6@gmail.com>
To: linux-input@vger.kernel.org, linux-hardening@vger.kernel.org
Cc: Marcus Folkesson <marcus.folkesson@gmail.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Ville Syrjala <syrjala@sci.fi>,
Henk Vergonet <Henk.Vergonet@gmail.com>,
Henrik Rydberg <rydberg@bitmath.org>,
linux-kernel@vger.kernel.org,
Shihuang Liu <shlomojune6@gmail.com>
Subject: [PATCH 5/5] Input: touchscreen - replace strlcat() with strscpy()
Date: Sat, 17 Oct 2026 01:04:11 +0800 [thread overview]
Message-ID: <20261016170411.51025-6-shlomojune6@gmail.com> (raw)
In-Reply-To: <20261016170411.51025-1-shlomojune6@gmail.com>
The sur40 and usbtouchscreen drivers build the physical path by
appending a constant "/input0" suffix with strlcat() after
usb_make_path().
In preparation for removing the deprecated strlcat() API[1],
replace it with strnlen() followed by strscpy() into the remainder
of the buffer, as commit 34b228b739f5 ("HID: usbhid: replace
strlcat with better alternatives") did for the usbhid drivers.
Link: https://github.com/KSPP/linux/issues/370 [1]
Signed-off-by: Shihuang Liu <shlomojune6@gmail.com>
---
drivers/input/touchscreen/sur40.c | 4 +++-
drivers/input/touchscreen/usbtouchscreen.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index 77ec2c94b91fd..72ec3882e3d40 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -657,6 +657,7 @@ static int sur40_probe(struct usb_interface *interface,
struct usb_endpoint_descriptor *endpoint;
struct input_dev *input;
int error;
+ size_t len;
/* Check if we really have the right interface. */
iface_desc = interface->cur_altsetting;
@@ -691,7 +692,8 @@ static int sur40_probe(struct usb_interface *interface,
input->name = DRIVER_LONG;
usb_to_input_id(usbdev, &input->id);
usb_make_path(usbdev, sur40->phys, sizeof(sur40->phys));
- strlcat(sur40->phys, "/input0", sizeof(sur40->phys));
+ len = strnlen(sur40->phys, sizeof(sur40->phys));
+ strscpy(sur40->phys + len, "/input0", sizeof(sur40->phys) - len);
input->phys = sur40->phys;
input->dev.parent = &interface->dev;
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 0bbacb517c286..e6f88bd9a3408 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -1438,6 +1438,7 @@ static int usbtouch_probe(struct usb_interface *intf,
struct usb_device *udev = interface_to_usbdev(intf);
const struct usbtouch_device_info *type;
int err;
+ size_t len;
/* some devices are ignored */
type = (const struct usbtouch_device_info *)id->driver_info;
@@ -1513,7 +1514,8 @@ static int usbtouch_probe(struct usb_interface *intf,
le16_to_cpu(udev->descriptor.idProduct));
usb_make_path(udev, usbtouch->phys, sizeof(usbtouch->phys));
- strlcat(usbtouch->phys, "/input0", sizeof(usbtouch->phys));
+ len = strnlen(usbtouch->phys, sizeof(usbtouch->phys));
+ strscpy(usbtouch->phys + len, "/input0", sizeof(usbtouch->phys) - len);
input_dev->name = usbtouch->name;
input_dev->phys = usbtouch->phys;
--
2.43.0
prev parent reply other threads:[~2026-10-16 17:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 17:04 [PATCH 0/5] Input: replace strlcat() with strscpy() in USB input drivers Shihuang Liu
2026-10-16 17:04 ` [PATCH 1/5] Input: joystick - replace strlcat() with strscpy() Shihuang Liu
2026-10-16 19:17 ` Dmitry Torokhov
2026-10-17 8:19 ` Greg KH
2026-10-16 17:04 ` [PATCH 2/5] Input: misc " Shihuang Liu
2026-10-16 17:04 ` [PATCH 3/5] Input: mouse " Shihuang Liu
2026-10-16 17:04 ` [PATCH 4/5] Input: tablet " Shihuang Liu
2026-10-16 17:04 ` Shihuang Liu [this message]
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=20261016170411.51025-6-shlomojune6@gmail.com \
--to=shlomojune6@gmail.com \
--cc=Henk.Vergonet@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcus.folkesson@gmail.com \
--cc=rydberg@bitmath.org \
--cc=syrjala@sci.fi \
/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
all inboxes | Powered by JetHome®