lkml.org 
[lkml]   [2014]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] staging: lustre: lustre: ptlrpc: sec.c: Replacing strncat with strlcat to avoid overwrite size
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


\
 
 \ /
  Last update: 2014-10-13 17:01    [W:0.053 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site