* [PATCH] usb: typec: tcpm: replace strcpy with strscpy
@ 2026-04-19 21:36 Maxwell Doose
0 siblings, 0 replies; only message in thread
From: Maxwell Doose @ 2026-04-19 21:36 UTC (permalink / raw)
To: badhri, heikki.krogerus, gregkh; +Cc: linux-usb, linux-kernel
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@gmail.com>
---
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",
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-19 21:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-19 21:36 [PATCH] usb: typec: tcpm: replace strcpy with strscpy Maxwell Doose
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox