-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix file length not matching file name because of multi-byte UTF-16 #1859
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, everything looks great, i've requested some minor corrections to avoid repeating code
@@ -1171,7 +1171,7 @@ def connectTree(self, share): | |||
|
|||
treeConnect = SMB2TreeConnect() | |||
treeConnect['Buffer'] = path.encode('utf-16le') | |||
treeConnect['PathLength'] = len(path)*2 | |||
treeConnect['PathLength'] = len(path.encode('utf-16le')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
treeConnect['PathLength'] = len(path.encode('utf-16le')) | |
treeConnect['PathLength'] = len(treeConnect['Buffer']) |
queryDirectory['FileNameLength'] = len(searchString.encode('utf-16le')) | ||
queryDirectory['Buffer'] = searchString.encode('utf-16le') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
queryDirectory['FileNameLength'] = len(searchString.encode('utf-16le')) | |
queryDirectory['Buffer'] = searchString.encode('utf-16le') | |
queryDirectory['Buffer'] = searchString.encode('utf-16le') | |
queryDirectory['FileNameLength'] = len(queryDirectory['Buffer']) | |
renameReq['FileNameLength'] = len(newPath.encode('utf-16le')) | ||
renameReq['FileName'] = newPath.encode('utf-16le') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renameReq['FileNameLength'] = len(newPath.encode('utf-16le')) | |
renameReq['FileName'] = newPath.encode('utf-16le') | |
renameReq['FileName'] = newPath.encode('utf-16le') | |
renameReq['FileNameLength'] = len(renameReq['FileName']) | |
pipeWait['NameLength'] = len(pipename.encode('utf-16le')) | ||
pipeWait['TimeoutSpecified'] = 1 | ||
pipeWait['Name'] = pipename.encode('utf-16le') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pipeWait['NameLength'] = len(pipename.encode('utf-16le')) | |
pipeWait['TimeoutSpecified'] = 1 | |
pipeWait['Name'] = pipename.encode('utf-16le') | |
pipeWait['Name'] = pipename.encode('utf-16le') | |
pipeWait['NameLength'] = len(pipeWait['Name'] ) | |
pipeWait['TimeoutSpecified'] = 1 | |
Fixes #1796
Before, filenames with multi-byte symbols such as emojis cut off the filename in several cases:
There are still some of these left in the code, but I did not know if the encoding can be assumed in those cases, whereas in the cases I fixed it was already assumed to be UTF-16LE
Here is a rough grep for the remaining cases: