mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-29 08:44:52 +02:00
Multiple Fixes
https://github.com/PowerShell/Win32-OpenSSH/issues/496 https://github.com/PowerShell/Win32-OpenSSH/issues/488 https://github.com/PowerShell/Win32-OpenSSH/issues/495
This commit is contained in:
parent
d10d8a8f36
commit
e4da8db4d2
@ -74,6 +74,7 @@ typedef struct _SCREEN_RECORD{
|
||||
}SCREEN_RECORD,*PSCREEN_RECORD;
|
||||
|
||||
PSCREEN_RECORD pSavedScreenRec = NULL;
|
||||
int in_raw_mode = 0;
|
||||
|
||||
/* ************************************************************ */
|
||||
/* Function: ConInit */
|
||||
@ -135,6 +136,7 @@ int ConInit( DWORD OutputHandle, BOOL fSmartInit )
|
||||
if (GetConsoleScreenBufferInfo(hOutputConsole, &csbi))
|
||||
SavedViewRect = csbi.srWindow;
|
||||
|
||||
in_raw_mode = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -147,6 +149,7 @@ int ConUnInit( void )
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo;
|
||||
|
||||
in_raw_mode = 0;
|
||||
if ( hOutputConsole == NULL )
|
||||
return 0;
|
||||
|
||||
|
@ -1069,15 +1069,15 @@ int start_with_pty(int ac, wchar_t **av) {
|
||||
/*TODO - pick this up from system32*/
|
||||
cmd[0] = L'\0';
|
||||
if (ac)
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, L"cmd.exe"));
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L"cmd.exe"));
|
||||
|
||||
ac--;
|
||||
av++;
|
||||
if (ac)
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, L" /c"));
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" /c"));
|
||||
while (ac) {
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, L" "));
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, *av));
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" "));
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, *av));
|
||||
ac--;
|
||||
av++;
|
||||
}
|
||||
@ -1183,14 +1183,14 @@ int start_withno_pty(int ac, wchar_t **av) {
|
||||
|
||||
/*TODO - pick this up from system32*/
|
||||
cmd[0] = L'\0';
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, L"cmd.exe"));
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L"cmd.exe"));
|
||||
ac -= 2;
|
||||
av += 2;
|
||||
if (ac)
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, L" /c"));
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" /c"));
|
||||
while (ac) {
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, L" "));
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, PATH_MAX, *av));
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, L" "));
|
||||
GOTO_CLEANUP_ON_ERR(wcscat_s(cmd, MAX_CMD_LEN, *av));
|
||||
ac--;
|
||||
av++;
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
#define TERM_IO_BUF_SIZE 2048
|
||||
|
||||
extern int in_raw_mode;
|
||||
|
||||
struct io_status {
|
||||
DWORD to_transfer;
|
||||
DWORD transferred;
|
||||
@ -129,13 +131,7 @@ static DWORD WINAPI WriteThread(
|
||||
DWORD dwSavedAttributes = ENABLE_PROCESSED_INPUT;
|
||||
debug3("TermWrite thread, io:%p", pio);
|
||||
|
||||
/* decide to call parsing engine or directly write to console
|
||||
* doing the following trick to decide -
|
||||
* if console in handle is set to process Ctrl+C, then it is likely
|
||||
* serving a PTY enabled session
|
||||
*/
|
||||
GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &dwSavedAttributes);
|
||||
if (dwSavedAttributes & ENABLE_PROCESSED_INPUT) {
|
||||
if (in_raw_mode == 0) {
|
||||
/* convert stream to utf16 and dump on console */
|
||||
pio->write_details.buf[write_status.to_transfer] = '\0';
|
||||
wchar_t* t = utf8_to_utf16(pio->write_details.buf);
|
||||
@ -143,7 +139,7 @@ static DWORD WINAPI WriteThread(
|
||||
free(t);
|
||||
write_status.transferred = write_status.to_transfer;
|
||||
} else {
|
||||
|
||||
/* console mode */
|
||||
telProcessNetwork(pio->write_details.buf, write_status.to_transfer, &respbuf, &resplen);
|
||||
/*TODO - respbuf is not null in some cases, this needs to be returned back via read stream*/
|
||||
write_status.transferred = write_status.to_transfer;
|
||||
|
27
sftp.c
27
sftp.c
@ -298,17 +298,14 @@ help(void)
|
||||
static void printf_utf8(char *fmt, ... ) {
|
||||
/* TODO - is 1024 sufficient */
|
||||
char buf[1024];
|
||||
wchar_t* wtmp;
|
||||
int length = 0;
|
||||
|
||||
va_list valist;
|
||||
va_start(valist, fmt);
|
||||
|
||||
vsnprintf(buf, 1024, fmt, valist);
|
||||
length = vsnprintf(buf, 1024, fmt, valist);
|
||||
va_end(valist);
|
||||
|
||||
if ((wtmp = utf8_to_utf16(buf)) == NULL)
|
||||
fatal("unable to allocate memory");
|
||||
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), wtmp, wcslen(wtmp), 0, 0);
|
||||
free(wtmp);
|
||||
write(STDOUT_FILENO, buf, length);
|
||||
}
|
||||
|
||||
/* override mprintf */
|
||||
@ -931,11 +928,17 @@ do_ls_dir(struct sftp_conn *conn, const char *path,
|
||||
#ifdef WINDOWS
|
||||
/* cannot use printf_utf8 becuase of width specification */
|
||||
/* printf_utf8 does not account for utf-16 based argument widths */
|
||||
char *p = NULL;
|
||||
wchar_t buf[1024];
|
||||
wchar_t* wtmp = utf8_to_utf16(fname);
|
||||
swprintf(buf, 1024, L"%-*s", colspace, wtmp);
|
||||
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), buf, wcslen(buf), 0, 0);
|
||||
|
||||
if ((p = utf16_to_utf8(buf)) == NULL)
|
||||
continue;
|
||||
|
||||
write(STDOUT_FILENO, p, strlen(p));
|
||||
free(wtmp);
|
||||
free(p);
|
||||
#else
|
||||
mprintf("%-*s", colspace, fname);
|
||||
#endif
|
||||
@ -1025,11 +1028,17 @@ do_globbed_ls(struct sftp_conn *conn, const char *path,
|
||||
#ifdef WINDOWS
|
||||
/* cannot use printf_utf8 becuase of width specification */
|
||||
/* printf_utf8 does not account for utf-16 based argument widths */
|
||||
char *p = NULL;
|
||||
wchar_t buf[1024];
|
||||
wchar_t* wtmp = utf8_to_utf16(fname);
|
||||
swprintf(buf, 1024, L"%-*s", colspace, wtmp);
|
||||
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), buf, wcslen(buf), 0, 0);
|
||||
|
||||
if ((p = utf16_to_utf8(buf)) == NULL)
|
||||
continue;
|
||||
|
||||
write(STDOUT_FILENO, p, strlen(p));
|
||||
free(wtmp);
|
||||
free(p);
|
||||
#else
|
||||
mprintf("%-*s", colspace, fname);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user