From: Maxwell Doose <m32285159@gmail.com>
To: badhri@google.com, heikki.krogerus@linux.intel.com,
gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] usb: typec: tcpm: replace strcpy with strscpy
Date: Sun, 19 Apr 2026 16:36:38 -0500 [thread overview]
Message-ID: <20260419213638.38291-2-m32285159@gmail.com> (raw)
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
reply other threads:[~2026-04-19 21:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260419213638.38291-2-m32285159@gmail.com \
--to=m32285159@gmail.com \
--cc=badhri@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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