namjaejeon/ksmbd

KSMBD cannot open folders in other languages

Closed this issue · 2 comments

When I put this project on a Linux 5.4 machine and access it using the SMB1 protocol, if I create a Chinese name directory, the last word KSMBD will encode incorrectly, which will cause the terminal to be unable to access the folder.
Through my testing, I found that when accessing the SMB1 protocol, the UTF16 encoding of the project will encode all bytes of the last word as 0, such as encoding \ u2b59 as \ u2b00, \ u2959 as \ u2900. When the last word is in Chinese, Russian, Korean, etc., the above errors will occur.
I hope you can check the encoding processing of this code and resolve this bug.

@zzqziv You have closed this issue. Did you found any solution for this ?

@zzqziv You have closed this issue. Did you found any solution for this ?
The problem should be like this: in the latest version of the code, the Filename[1] in file_both_directory_info has been changed to Filename[], and the last bit of the flexible array Filename[] does not occupy memory. However, the data structure was not maintained during the decoding of smb_populate_readdir_entry, and an additional byte was still subtracted(e.g. memset((char *)ffdinfo + struct_sz - 1 + conv_len,'\0',next_entry_offset - struct_sz - 1 + conv_len);), resulting in the loss of the last encoded byte. Subsequent processing of smb1 recognizes all the last missing bytes as 0x00. The encoding of the second byte of letters utf16 in English is not affected as 0x00, but errors may occur in other languages such as Chinese.