lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a886478f-e068-415a-44b6-e31a6d593a48@kernel.org>
Date:   Tue, 28 Aug 2018 15:48:20 -0600
From:   Shuah Khan <shuah@...nel.org>
To:     Anders Roxell <anders.roxell@...aro.org>, trenn@...e.com
Cc:     linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        Shuah Khan <shuah@...nel.org>
Subject: Re: [PATCH v2] cpupower: remove stringop-truncation waring

On 08/28/2018 03:31 AM, Anders Roxell wrote:
> The strncpy doesn't null terminate the string because the size is too
> short by one byte.
> 
> parse.c: In function ‘prepare_default_config’:
> parse.c:148:2: warning: ‘strncpy’ output truncated before terminating
>     nul copying 8 bytes from a string of the same length
>     [-Wstringop-truncation]
>   strncpy(config->governor, "ondemand", 8);
>   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> The normal method of passing the length of the destination buffer works
> correctly here.
> 
> Fixes: 7fe2f6399a84 ("cpupowerutils - cpufrequtils extended with quite some features")
> Signed-off-by: Anders Roxell <anders.roxell@...aro.org>
> ---
>  tools/power/cpupower/bench/parse.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/power/cpupower/bench/parse.c b/tools/power/cpupower/bench/parse.c
> index 9ba8a44ad2a7..84caee38418f 100644
> --- a/tools/power/cpupower/bench/parse.c
> +++ b/tools/power/cpupower/bench/parse.c
> @@ -145,7 +145,7 @@ struct config *prepare_default_config()
>  	config->cpu = 0;
>  	config->prio = SCHED_HIGH;
>  	config->verbose = 0;
> -	strncpy(config->governor, "ondemand", 8);
> +	strncpy(config->governor, "ondemand", sizeof(config->governor));
>  
>  	config->output = stdout;
>  
> 

Thanks. Applied to cpupower git for 4.19-rc3

thanks,
-- Shuah

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ