-
Notifications
You must be signed in to change notification settings - Fork 167
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
Long environment strings are being truncated. #13
Comments
Thanks for reporting this issue. I'll try to look at it this weekend when I get time. |
FWIW, the "unix adapter" in winpty passes NULL for the winpty_start_process function. It doesn't send anything over IPC. I see that https://github.com/chjj/pty.js/blob/master/src/win/pty.cc is passing a non-NULL env parameter, though. I think there may be misunderstanding about that parameter. From the winpty.h header:
From pty.js/src/win/pty.cc: const wchar_t *env = ToWChar(String::Utf8Value(args[3]->ToString())); AFAICT, the string returned by ToWChar will have no embedded NUL characters and will end with one NUL character. I was intending the winpty_start_process API to accept an environment block like that of CreateProcess -- a sequence of VAR=VAL strings, separated by NUL characters, terminated by two NULs (one for the last string and one for the block itself). That's also the reason for the p++ on https://github.com/rprichard/winpty/blob/master/libwinpty/winpty.cc#L373. The p++ is skipping over the final NUL terminator of the environment block. The following envStr.assign(env, p); line then assigns the (p - env) characters to envStr, so that envStr is the complete double-NUL-terminated environment block. |
@rprichard Sorry about that, but you are looking at the wrong source code. Please see https://github.com/peters/pty.js/blob/master/src/win/pty.cc |
Fixed in peters/pty.js@e18e8f9 |
@rprichard If you try to start a new tty with a long environment string, it get's truncated.
Reading up on http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx no mention of a size limitation in the unicode version, only the ansi one.
If you put a trace in https://github.com/rprichard/winpty/blob/master/agent/Agent.cc#L193 you can clearly see a truncated string in the env variable. Only 35% of the content is transmitted via the IPC channel.
Also there's a bug in winpty.cc: https://github.com/rprichard/winpty/blob/master/libwinpty/winpty.cc#L373
Example:
The text was updated successfully, but these errors were encountered: