Re: [PATCH 1/2] ksmbd: casefold utf-8 share names and fix ascii lowercase conversion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2022-09-12 5:57 GMT+09:00, Atte Heikkilä <atteh.mailbox@xxxxxxxxx>:
Hi Atte,

[snip]
> +static char *casefold_sharename(struct unicode_map *um, const char *name)
> +{
> +	char *cf_name;
> +	int cf_len;
> +
> +	cf_name = kzalloc(KSMBD_REQ_MAX_SHARE_NAME, GFP_KERNEL);
> +	if (!cf_name)
> +		return ERR_PTR(-ENOMEM);
> +
> +	if (IS_ENABLED(CONFIG_UNICODE)) {
> +		const struct qstr q_name = {.name = name, .len = strlen(name)};
> +
> +		if (!um)
> +			goto out_ascii;
Minor nit, Wouldn't it be simpler to change something like the one below?

+	if (IS_ENABLED(CONFIG_UNICODE) && um) {

Thanks!
> +
> +		cf_len = utf8_casefold(um, &q_name, cf_name,
> +				       KSMBD_REQ_MAX_SHARE_NAME);
> +		if (cf_len < 0)
> +			goto out_ascii;
> +
> +		return cf_name;
> +	}
> +
> +out_ascii:
> +	cf_len = strscpy(cf_name, name, KSMBD_REQ_MAX_SHARE_NAME);
> +	if (cf_len < 0)
> +		return ERR_PTR(-E2BIG);
> +
> +	for (; *cf_name; ++cf_name)
> +		*cf_name = isascii(*cf_name) ? tolower(*cf_name) : *cf_name;
> +	return cf_name - cf_len;
> +}
> +




[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux