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

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

 



On Mon, 12 Sep 2022 19:20:54 +0900, Namjae Jeon wrote:
>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) {

This mailing list already has a v2 patch series. Please, reply to that one.
As for your suggestion, I thought to keep the statements separate since the
block with the IS_ENABLED() macro is optimized away when CONFIG_UNICODE is
not set. I understand that the behavior is the same with your suggestion.

Thank you.

>
>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