Re: [PATCH] usb: typec: tcpm: replace strcpy with strscpy

From: Amit Sunil Dhamne

Date: Thu Apr 23 2026 - 15:25:56 EST


Hi Maxwell,

On 4/19/26 2:36 PM, Maxwell Doose wrote:
The function strcpy() is deprecated as it can be used in buffer overflow
attacks. This patch replaces strcpy() with strscpy() to improve
security and stability.

Signed-off-by: Maxwell Doose <m32285159@xxxxxxxxx>
---
drivers/usb/typec/tcpm/tcpm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 8e0e14a2704e..69574c5e79e1 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -725,7 +725,7 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
if (tcpm_log_full(port)) {
port->logbuffer_head = max(port->logbuffer_head - 1, 0);
- strcpy(tmpbuffer, "overflow");
+ strscpy(tmpbuffer, "overflow", sizeof(tmpbuffer))
}
if (port->logbuffer_head < 0 ||
@@ -841,10 +841,10 @@ static void tcpm_log_source_caps(struct tcpm_port *port)
pdo_spr_avs_apdo_15v_to_20v_max_current_ma(pdo),
pdo_spr_avs_apdo_src_peak_current(pdo));
else
- strcpy(msg, "undefined APDO");
+ strscpy(msg, "undefined APDO", sizeof(msg));
break;
default:
- strcpy(msg, "undefined");
+ strscpy(msg, "undefined", sizeof(msg));
break;
}
tcpm_log(port, " PDO %d: type %d, %s",

This has already been fixed as part of [1].

[1] https://patch.msgid.link/20260310094434.3639602-5-aichao@xxxxxxxxxx


BR,

Amit