VirtualFileSystemHook: ensure string is properly null terminated#165
VirtualFileSystemHook: ensure string is properly null terminated#165jamill merged 1 commit intomicrosoft:masterfrom
Conversation
|
|
||
| messageLength = bytesRead; | ||
| message[bytesRead] = 0; |
There was a problem hiding this comment.
@benpeart can check my thinking here, but the paths are NUL separated so couldn't this create an invalid path by putting a NUL in the middle of a path? The read from the pipe is not guaranteed to send based on the paths is it?
There was a problem hiding this comment.
Valid concern - and maybe we should only add the null character if we are about to write the message out to string.
However, the null character is being added outside of the message, and is not part of the bytesRead (and hence not part of the actual pipe message)?
benpeart
left a comment
There was a problem hiding this comment.
The problem here is that GVFS doesn't null terminate the error message passed across the named pipe but the hook assumes it does. We can fix either end. Fixing the hook works.
103b701 to
a22b04e
Compare
benpeart
left a comment
There was a problem hiding this comment.
This looks better. It's safer to only munge with the buffer in the case of an error.
266e0af to
696985d
Compare
When the VirtualFileSystem hook receives an error reading data from GVFS over a named pipe, it will include the pipe message in the error message. The pipe message is not necassarily null terminated, so we need to append a null terminating character before passing it to string formatting functions that expect a null terminated string. This change makes sure the message is null terminated.
696985d to
32cb916
Compare
When the VirtualFileSystem hook receives an error reading data from GVFS
over a named pipe, it will include the pipe message in the error
message. The pipe message is not necassarily null terminated, so we need
to append a null terminating character before passing it to string
formatting functions that expect a null terminated string.
This change makes sure the message is null terminated.