From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Su Hui <suhui@nfschina.com>
Cc: rafael.j.wysocki@intel.com, kernel-janitors@vger.kernel.org,
robert.moore@intel.com, linux-kernel@vger.kernel.org,
linux-acpi@vger.kernel.org,
acpica-devel@lists.linuxfoundation.org, lenb@kernel.org
Subject: Re: [Acpica-devel] [PATCH 1/2] ACPICA: Use strscpy to replace strncpy
Date: Thu, 31 Aug 2023 11:35:24 +0200 [thread overview]
Message-ID: <CAJZ5v0iBZhz6oRgzU3_E+TFT244cgcWxS5ufo_8LnsgvrbbTJQ@mail.gmail.com> (raw)
In-Reply-To: <20230831073432.1712904-1-suhui@nfschina.com>
On Thu, Aug 31, 2023 at 9:35 AM Su Hui <suhui@nfschina.com> wrote:
>
> With gcc and W=1 option to compile kernel, warning happens:
>
> inlined from ‘acpi_tb_find_table’ at drivers/acpi/acpica/tbfind.c:60:2:
> include/linux/fortify-string.h:68:30: error: ‘__builtin_strncpy’ specified
> bound 6 equals destination size [-Werror=stringop-truncation]
>
> Use strscpy to avoid this warning and is safer.
>
> Signed-off-by: Su Hui <suhui@nfschina.com>
Please see
https://lore.kernel.org/linux-acpi/202308241612.DFE4119@keescook/
> ---
> drivers/acpi/acpica/tbfind.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c
> index 1c1b2e284bd9..5536d1755188 100644
> --- a/drivers/acpi/acpica/tbfind.c
> +++ b/drivers/acpi/acpica/tbfind.c
> @@ -57,8 +57,8 @@ acpi_tb_find_table(char *signature,
>
> memset(&header, 0, sizeof(struct acpi_table_header));
> ACPI_COPY_NAMESEG(header.signature, signature);
> - strncpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
> - strncpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
> + strscpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
> + strscpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
>
> /* Search for the table */
>
> --
> 2.30.2
>
prev parent reply other threads:[~2023-08-31 9:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-31 7:41 [Acpica-devel] [PATCH 1/2] ACPICA: Use strscpy to replace strncpy Su Hui
2023-08-31 9:35 ` Rafael J. Wysocki [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=CAJZ5v0iBZhz6oRgzU3_E+TFT244cgcWxS5ufo_8LnsgvrbbTJQ@mail.gmail.com \
--to=rafael@kernel.org \
--cc=acpica-devel@lists.linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=robert.moore@intel.com \
--cc=suhui@nfschina.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).