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: <f6a3zjnituwlspbsjhiy47anx2yf24fpzofhm2nablqsk4rj6l@qfsq7pyyakba>
Date: Thu, 13 Mar 2025 18:12:11 +0100
From: Jan Kara <jack@...e.cz>
To: ye.xingchen@....com.cn
Cc: brauner@...nel.org, jeff.johnson@....qualcomm.com, jack@...e.cz, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] nls: Fix utf8s_to_utf16s parameter type in declaration and definition

On Thu 13-03-25 16:36:01, ye.xingchen@....com.cn wrote:
> From: YeXingchen <ye.xingchen@....com.cn>
> 
> The declaration of utf8s_to_utf16s in the header file uses
> bool maxlen as the parameter type, while the definition uses bool maxout.
> 
> This patch aligns the parameter name in the definition with the
> declaration,changing inlen to len,maxout to maxlen to ensure consistency.
> 
> Signed-off-by: YeXingchen <ye.xingchen@....com.cn>

Thanks for the patches but you should rather be modifying prototypes in
include/linux/nls.h to match the real declaration. If you actually check
the history, you'll notice commit 045ddc8991698 modified the implementation
but forgot to update the prototypes in include/linux/nls.h. And the names
in the implementation are indeed more descriptive.

								Honza


> ---
> v1->v2
> fix the parameter
>  fs/nls/nls_base.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
> index 18d597e49a19..fcce6ff1380a 100644
> --- a/fs/nls/nls_base.c
> +++ b/fs/nls/nls_base.c
> @@ -129,24 +129,24 @@ static inline void put_utf16(wchar_t *s, unsigned c, enum utf16_endian endian)
>  	}
>  }
> 
> -int utf8s_to_utf16s(const u8 *s, int inlen, enum utf16_endian endian,
> -		wchar_t *pwcs, int maxout)
> +int utf8s_to_utf16s(const u8 *s, int len, enum utf16_endian endian,
> +		wchar_t *pwcs, int maxlen)
>  {
>  	u16 *op;
>  	int size;
>  	unicode_t u;
> 
>  	op = pwcs;
> -	while (inlen > 0 && maxout > 0 && *s) {
> +	while (len > 0 && maxlen > 0 && *s) {
>  		if (*s & 0x80) {
> -			size = utf8_to_utf32(s, inlen, &u);
> +			size = utf8_to_utf32(s, len, &u);
>  			if (size < 0)
>  				return -EINVAL;
>  			s += size;
> -			inlen -= size;
> +			len -= size;
> 
>  			if (u >= PLANE_SIZE) {
> -				if (maxout < 2)
> +				if (maxlen < 2)
>  					break;
>  				u -= PLANE_SIZE;
>  				put_utf16(op++, SURROGATE_PAIR |
> @@ -156,15 +156,15 @@ int utf8s_to_utf16s(const u8 *s, int inlen, enum utf16_endian endian,
>  						SURROGATE_LOW |
>  						(u & SURROGATE_BITS),
>  						endian);
> -				maxout -= 2;
> +				maxlen -= 2;
>  			} else {
>  				put_utf16(op++, u, endian);
> -				maxout--;
> +				maxlen--;
>  			}
>  		} else {
>  			put_utf16(op++, *s++, endian);
> -			inlen--;
> -			maxout--;
> +			len--;
> +			maxlen--;
>  		}
>  	}
>  	return op - pwcs;
> -- 
> 2.25.1
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ