All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx+linux-hardening@kernel.org>
To: Mariia Nikitash <nikitash.mariiaw@gmail.com>
Cc: Hans Verkuil <hverkuil@kernel.org>,
	 Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-hardening@vger.kernel.org, Kees Cook <kees@kernel.org>,
	 Justin Stitt <justinstitt@google.com>,
	Bill Wendling <morbo@google.com>,
	 David Laight <david.laight.linux@gmail.com>
Subject: Re: [PATCH v2] media: radio: Replace strlcat() with scnprintf() in TEA drivers
Date: Sat, 5 Dec 2026 11:28:32 +0100	[thread overview]
Message-ID: <axPmz3NFRjKWee-u@devuan> (raw)
In-Reply-To: <20261204-strlcat-removal-tea-radio-v2-1-107a2e4c9d61@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2696 bytes --]

Hi Mariia,

> Date: 2026-12-04 18:03:33-0800
> From: Mariia Nikitash <nikitash.mariiaw@gmail.com>
>
> In preparation for removing the deprecated strlcat() API[1],
> replace the strscpy() and strlcat() calls used to construct
> V4L2 card names in the TEA5777 and TEA575x radio drivers.
> 
> Construct each card name with a single scnprintf() call, preserving
> the original output and truncation behavior.
> 
> Link: https://github.com/KSPP/linux/issues/370 [1]
> Signed-off-by: Mariia Nikitash <nikitash.mariiaw@gmail.com>
> ---
> Changes in v2:
> - Use scnprintf() instead of seq_buf based on reviewer feedback.
> ---
>  drivers/media/radio/radio-tea5777.c | 3 +--
>  drivers/media/radio/tea575x.c       | 4 ++--
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/radio/radio-tea5777.c b/drivers/media/radio/radio-tea5777.c
> index fb9de7bbcd19..63e7369bedad 100644
> --- a/drivers/media/radio/radio-tea5777.c
> +++ b/drivers/media/radio/radio-tea5777.c
> @@ -257,8 +257,7 @@ static int vidioc_querycap(struct file *file, void  *priv,
>  	struct radio_tea5777 *tea = video_drvdata(file);
>  
>  	strscpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver));
> -	strscpy(v->card, tea->card, sizeof(v->card));
> -	strlcat(v->card, " TEA5777", sizeof(v->card));
> +	scnprintf(v->card, sizeof(v->card), "%s TEA5777", tea->card);

Should we use ARRAY_SIZE() instead of sizeof()?  It will make sure that
v->card is actually an array.  And since it's a char array, it shouldn't
matter whether we count the number of elements or the size in bytes.

In any case,

Reviewed-by: Alejandro Colomar <alx@kernel.org>


Have a lovely day!
Alex

>  	strscpy(v->bus_info, tea->bus_info, sizeof(v->bus_info));
>  	return 0;
>  }
> diff --git a/drivers/media/radio/tea575x.c b/drivers/media/radio/tea575x.c
> index c37315226c42..9a91ccedcf30 100644
> --- a/drivers/media/radio/tea575x.c
> +++ b/drivers/media/radio/tea575x.c
> @@ -223,8 +223,8 @@ static int vidioc_querycap(struct file *file, void  *priv,
>  	struct snd_tea575x *tea = video_drvdata(file);
>  
>  	strscpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver));
> -	strscpy(v->card, tea->card, sizeof(v->card));
> -	strlcat(v->card, tea->tea5759 ? " TEA5759" : " TEA5757", sizeof(v->card));
> +	scnprintf(v->card, sizeof(v->card), "%s%s", tea->card,
> +		  tea->tea5759 ? " TEA5759" : " TEA5757");
>  	strscpy(v->bus_info, tea->bus_info, sizeof(v->bus_info));
>  	return 0;
>  }
> 
> ---
> base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d
> change-id: 20261203-strlcat-removal-tea-radio-8a531e00f706
> 

-- 
<https://www.alejandro-colomar.es>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2026-12-05 10:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06  7:46 [PATCH] media: radio: Replace strlcat() with seq_buf in TEA drivers Mariia Nikitash
2026-11-06 10:39 ` Alejandro Colomar
2026-11-07  4:31   ` Mariia Nikitash
2026-11-07  7:39     ` Alejandro Colomar
2026-11-08 21:02 ` David Laight
2026-11-08 21:25   ` Alejandro Colomar
2026-11-12 17:54     ` Kees Cook
2026-11-12 19:07       ` David Laight
2026-11-12 20:31         ` Kees Cook
2026-11-12 22:07       ` Alejandro Colomar
2026-11-10 10:08 ` Hans Verkuil
2026-11-10 13:54   ` David Laight
2026-11-10 18:41     ` Mariia Nikitash
2026-11-10 20:58       ` David Laight
2026-12-05  2:03 ` [PATCH v2] media: radio: Replace strlcat() with scnprintf() " Mariia Nikitash
2026-12-05 10:28   ` Alejandro Colomar [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=axPmz3NFRjKWee-u@devuan \
    --to=alx+linux-hardening@kernel.org \
    --cc=david.laight.linux@gmail.com \
    --cc=hverkuil@kernel.org \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=morbo@google.com \
    --cc=nikitash.mariiaw@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.