linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chen Gang <gang.chen.5i5j@gmail.com>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Oleg Drokin <oleg.drokin@intel.com>
Cc: Andreas Dilger <andreas.dilger@intel.com>,
	Andriy Skulysh <Andriy_Skulysh@xyratex.com>,
	Liang Zhen <liang.zhen@intel.com>,
	Denis Pithon <denis.pithon@gmail.com>,
	Patrick Farrell <paf@cray.com>,
	Masanari Iida <standby24x7@gmail.com>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: lustre: lustre: ptlrpc: sec.c:  Replacing strncat with strlcat to avoid overwrite size
Date: Mon, 13 Oct 2014 22:39:11 +0800	[thread overview]
Message-ID: <543BE40F.1050509@gmail.com> (raw)
In-Reply-To: <1413129333-19863-1-git-send-email-rickard_strandqvist@spectrumdigital.se>

On 10/12/14 23:55, Rickard Strandqvist wrote:
> Changed from using strncat with strlcat to avoid overwrite the max size.
> Take the opportunity to change a snprint to strlcpy.
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>  drivers/staging/lustre/lustre/ptlrpc/sec.c |    5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c
> index 5cff7ee..d276e98 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
> @@ -209,7 +209,7 @@ EXPORT_SYMBOL(sptlrpc_flavor2name_bulk);
>  
>  char *sptlrpc_flavor2name(struct sptlrpc_flavor *sf, char *buf, int bufsize)
>  {
> -	snprintf(buf, bufsize, "%s", sptlrpc_flavor2name_base(sf->sf_rpc));
> +	strlcpy(buf, sptlrpc_flavor2name_base(sf->sf_rpc), bufsize);
>  
>  	/*
>  	 * currently we don't support customized bulk specification for
> @@ -220,10 +220,9 @@ char *sptlrpc_flavor2name(struct sptlrpc_flavor *sf, char *buf, int bufsize)
>  
>  		bspec[0] = '-';
>  		sptlrpc_flavor2name_bulk(sf, &bspec[1], sizeof(bspec) - 1);
> -		strncat(buf, bspec, bufsize);
> +		strlcat(buf, bspec, bufsize);
>  	}
>  
> -	buf[bufsize - 1] = '\0';
>  	return buf;
>  }
>  EXPORT_SYMBOL(sptlrpc_flavor2name);
> 

At least for me, it is OK.

Acked-by: Chen Gang <gang.chen.5i5j@gmail.com>

Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed

      reply	other threads:[~2014-10-13 14:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-12 15:55 [PATCH] staging: lustre: lustre: ptlrpc: sec.c: Replacing strncat with strlcat to avoid overwrite size Rickard Strandqvist
2014-10-13 14:39 ` Chen Gang [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=543BE40F.1050509@gmail.com \
    --to=gang.chen.5i5j@gmail.com \
    --cc=Andriy_Skulysh@xyratex.com \
    --cc=andreas.dilger@intel.com \
    --cc=denis.pithon@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=liang.zhen@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg.drokin@intel.com \
    --cc=paf@cray.com \
    --cc=rickard_strandqvist@spectrumdigital.se \
    --cc=standby24x7@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;
as well as URLs for NNTP newsgroup(s).