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]
Date:   Mon, 08 Jan 2018 09:56:26 -0800
From:   Viacheslav Dubeyko <slava@...eyko.com>
To:     Xiongfeng Wang <wangxiongfeng2@...wei.com>,
        linux-fsdevel@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org, arnd@...db.de
Subject: Re: [PATCH] fs/hfsplus: use memcpy() instead of strncpy()

On Mon, 2018-01-08 at 20:17 +0800, Xiongfeng Wang wrote:
> From: Xiongfeng Wang <xiongfeng.wang@...aro.org>
> 
> gcc-8 reports
> 
> inlined from 'copy_name' at fs/hfsplus/xattr.c:416:3:
> ./include/linux/string.h:245:9: warning: '__builtin_strncpy' output
> truncated before terminating nul copying 4 bytes from a string of the
> same length [-Wstringop-truncation]
> 
> Since we don't need to copy '\0', we can just use memcpy() to avoid
> this
> warning.
> 

If the gcc-8 emits the warning then the suggested change makes sense.
Looks good.

Reviewed-by: Vyacheslav Dubeyko <slava@...eyko.com>

Thanks,
Vyacheslav Dubeyko.


> Signed-off-by: Xiongfeng Wang <xiongfeng.wang@...aro.org>
> ---
>  fs/hfsplus/xattr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
> index e538b75..0dc8a65 100644
> --- a/fs/hfsplus/xattr.c
> +++ b/fs/hfsplus/xattr.c
> @@ -413,7 +413,7 @@ static int copy_name(char *buffer, const char
> *xattr_name, int name_len)
>  	int offset = 0;
>  
>  	if (!is_known_namespace(xattr_name)) {
> -		strncpy(buffer, XATTR_MAC_OSX_PREFIX,
> XATTR_MAC_OSX_PREFIX_LEN);
> +		memcpy(buffer, XATTR_MAC_OSX_PREFIX,
> XATTR_MAC_OSX_PREFIX_LEN);
>  		offset += XATTR_MAC_OSX_PREFIX_LEN;
>  		len += XATTR_MAC_OSX_PREFIX_LEN;
>  	}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ