public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ley Foon Tan <ley.foon.tan@intel.com>
To: Wang Xiayang <xywang.sjtu@sjtu.edu.cn>
Cc: rppt@linux.vnet.ibm.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nios2: force the string buffer NULL-terminated
Date: Wed, 02 Oct 2019 08:52:30 +0800	[thread overview]
Message-ID: <1569977550.9826.7.camel@intel.com> (raw)
In-Reply-To: <20190805101712.22580-1-xywang.sjtu@sjtu.edu.cn>

On Mon, 2019-08-05 at 18:17 +0800, Wang Xiayang wrote:
> strncpy() does not ensure NULL-termination when the input string
> size equals to the destination buffer size COMMAND_LINE_SIZE.
> Besides, grep under arch/ with 'boot_command_line' shows
> no other arch-specific code uses strncpy() when copying
> boot_command_line.
> 
> Use strlcpy() instead.
> 
> This issue is identified by a Coccinelle script.
> 
> Signed-off-by: Wang Xiayang <xywang.sjtu@sjtu.edu.cn>
Merged to v5.4-rc1. Thanks.


Acked-by: Ley Foon Tan <ley.foon.tan@intel.com>


> ---
>  arch/nios2/kernel/setup.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c
> index 6bbd4ae2beb0..4cf35b09c0ec 100644
> --- a/arch/nios2/kernel/setup.c
> +++ b/arch/nios2/kernel/setup.c
> @@ -123,7 +123,7 @@ asmlinkage void __init nios2_boot_init(unsigned
> r4, unsigned r5, unsigned r6,
>                 dtb_passed = r6;
> 
>                 if (r7)
> -                       strncpy(cmdline_passed, (char *)r7,
> COMMAND_LINE_SIZE);
> +                       strlcpy(cmdline_passed, (char *)r7,
> COMMAND_LINE_SIZE);
>         }
>  #endif
> 
> @@ -131,10 +131,10 @@ asmlinkage void __init nios2_boot_init(unsigned
> r4, unsigned r5, unsigned r6,
> 
>  #ifndef CONFIG_CMDLINE_FORCE
>         if (cmdline_passed[0])
> -               strncpy(boot_command_line, cmdline_passed,
> COMMAND_LINE_SIZE);
> +               strlcpy(boot_command_line, cmdline_passed,
> COMMAND_LINE_SIZE);
>  #ifdef CONFIG_NIOS2_CMDLINE_IGNORE_DTB
>         else
> -               strncpy(boot_command_line, CONFIG_CMDLINE,
> COMMAND_LINE_SIZE);
> +               strlcpy(boot_command_line, CONFIG_CMDLINE,
> COMMAND_LINE_SIZE);
>  #endif
>  #endif
> 
> --
> 2.11.0
> 
> 
> ________________________________
> 
> Confidentiality Notice.
> This message may contain information that is confidential or
> otherwise protected from disclosure. If you are not the intended
> recipient, you are hereby notified that any use, disclosure,
> dissemination, distribution, or copying of this message, or any
> attachments, is strictly prohibited. If you have received this
> message in error, please advise the sender by reply e-mail, and
> delete the message and any attachments. Thank you.

      reply	other threads:[~2019-10-02  0:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-05 10:17 [PATCH] nios2: force the string buffer NULL-terminated Wang Xiayang
2019-10-02  0:52 ` Ley Foon Tan [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=1569977550.9826.7.camel@intel.com \
    --to=ley.foon.tan@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rppt@linux.vnet.ibm.com \
    --cc=xywang.sjtu@sjtu.edu.cn \
    /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