[sheepdog] [PATCH 1/2] checkpath: warn if we use strncpy()/strcpy()

Liu Yuan namei.unix at gmail.com
Wed Mar 4 08:20:52 CET 2015


On Wed, Mar 04, 2015 at 02:49:04PM +0800, Liu Yuan wrote:
> From: Liu Yuan <liuyuan at cmss.chinamobile.com>
> 
> Signed-off-by: Liu Yuan <liuyuan at cmss.chinamobile.com>
> ---
>  script/checkpatch.pl | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/script/checkpatch.pl b/script/checkpatch.pl
> index a00e43d..9762110 100755
> --- a/script/checkpatch.pl
> +++ b/script/checkpatch.pl
> @@ -2876,6 +2876,11 @@ sub process {
>  			ERROR("SPRINTF", "sprintf() is not buffer safe, use snprintf()\n" . $herecurr);
>  		}
>  
> +# forbid strncpy/strcpy
> +		if ($line =~ /\bstrncpy|\bstrcpy\(/) {
> +			ERROR("STRCPY", "strncpy()/strcpy is not buffer safe, use pstrcpy()\n" . $herecurr);
> +		}
> +
>  # 1. forbid empty lines after break; of a switch statement
>  # e.g.
>  # +        break;
> -- 
> 1.9.1
> 

Applied this series since they are straightforward and easy to justify. The other
reason is Yu Yang's patch would be affected by this two, so merge them as soon
as possible.

Yuan



More information about the sheepdog mailing list