public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Amit Sunil Dhamne <amitsd@google.com>
To: Maxwell Doose <m32285159@gmail.com>,
	badhri@google.com, heikki.krogerus@linux.intel.com,
	gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: typec: tcpm: replace strcpy with strscpy
Date: Thu, 23 Apr 2026 12:23:09 -0700	[thread overview]
Message-ID: <0643586e-e665-4592-b941-2868fca84322@google.com> (raw)
In-Reply-To: <20260419213638.38291-2-m32285159@gmail.com>

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@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",

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

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


BR,

Amit


  reply	other threads:[~2026-04-23 19:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-19 21:36 [PATCH] usb: typec: tcpm: replace strcpy with strscpy Maxwell Doose
2026-04-23 19:23 ` Amit Sunil Dhamne [this message]
2026-04-23 20:56   ` Maxwell Doose

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=0643586e-e665-4592-b941-2868fca84322@google.com \
    --to=amitsd@google.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 \
    --cc=m32285159@gmail.com \
    /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