From: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
To: justinstitt@google.com,
Cezary Rojewski <cezary.rojewski@intel.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
Liam Girdwood <liam.r.girdwood@linux.intel.com>,
Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
Kees Cook <keescook@chromium.org>,
Nathan Chancellor <nathan@kernel.org>
Subject: Re: [PATCH] ASoC: intel: avs: refactor strncpy usage in topology
Date: Wed, 26 Jul 2023 09:49:07 +0200 [thread overview]
Message-ID: <cce17be6-acdf-9737-f2cb-3559712e4c56@linux.intel.com> (raw)
In-Reply-To: <20230725-sound-soc-intel-avs-remove-deprecated-strncpy-v1-1-6357a1f8e9cf@google.com>
On 7/26/2023 12:08 AM, justinstitt@google.com wrote:
> `strncpy` is deprecated for use on NUL-terminated destination strings
> [1].
>
> A suitable replacement is `strscpy` [2].
>
> There are some hopes that someday the `strncpy` api could be ripped out
> due to the vast number of suitable replacements (strscpy, strscpy_pad,
> strtomem, strtomem_pad, strlcpy) [1].
>
> [1]: www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
> [2]: manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
>
> ---
>
>
> Link: https://github.com/KSPP/linux/issues/90
> Signed-off-by: Justin Stitt <justinstitt@google.com>
> ---
> sound/soc/intel/avs/topology.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/intel/avs/topology.c b/sound/soc/intel/avs/topology.c
> index cdb4ec500261..45d0eb2a8e71 100644
> --- a/sound/soc/intel/avs/topology.c
> +++ b/sound/soc/intel/avs/topology.c
> @@ -1388,12 +1388,12 @@ static int avs_route_load(struct snd_soc_component *comp, int index,
> port = __ffs(mach->mach_params.i2s_link_mask);
>
> snprintf(buf, len, route->source, port);
> - strncpy((char *)route->source, buf, len);
> + strscpy((char *)route->source, buf, len);
> snprintf(buf, len, route->sink, port);
> - strncpy((char *)route->sink, buf, len);
> + strscpy((char *)route->sink, buf, len);
> if (route->control) {
> snprintf(buf, len, route->control, port);
> - strncpy((char *)route->control, buf, len);
> + strscpy((char *)route->control, buf, len);
> }
> }
>
>
In this case snprintf adds NUL at the end and we strncpy using same
size, so there should always be NUL at the end, so replacing it with
strscpy shouldn't really change anything, so
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
next prev parent reply other threads:[~2023-07-26 7:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-25 22:08 justinstitt
2023-07-26 5:04 ` Kees Cook
2023-07-26 7:49 ` Amadeusz Sławiński [this message]
2023-07-26 11:49 ` Mark Brown
2023-07-26 18:08 ` Mark Brown
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=cce17be6-acdf-9737-f2cb-3559712e4c56@linux.intel.com \
--to=amadeuszx.slawinski@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=justinstitt@google.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=keescook@chromium.org \
--cc=liam.r.girdwood@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=tiwai@suse.com \
--cc=yung-chuan.liao@linux.intel.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
all inboxes | Powered by JetHome®