ACK: [PATCH] lib: fwts_args: use strncpy instead of strcpy

Alex Hung alex.hung at canonical.com
Thu May 21 22:55:08 UTC 2015


On 05/14/2015 04:33 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
> 
> Coverity Scan was flagging up the use of strcpy and of a potential
> buffer overrun, so use strncpy instead.
> 
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/lib/src/fwts_args.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lib/src/fwts_args.c b/src/lib/src/fwts_args.c
> index 86e0d4b..5dc9261 100644
> --- a/src/lib/src/fwts_args.c
> +++ b/src/lib/src/fwts_args.c
> @@ -299,8 +299,8 @@ void fwts_args_show_options(void)
>  				}
>  			}
>  		}
> -		strcat(ptr, "--");
> -		strcat(ptr, option->long_name);
> +		strncat(ptr, "--", ptr - buffer - 1);
> +		strncat(ptr, option->long_name, ptr - buffer - 3);
>  
>  		fwts_args_show_option(width, buffer, option->explanation);
>  	}
> 

Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list