From ca5de7fbbb36838e1ad84aac2b259a259c998072 Mon Sep 17 00:00:00 2001 From: Manoj Ampalam Date: Mon, 13 Mar 2017 00:18:22 -0700 Subject: [PATCH] Fixed remote commandline issue https://github.com/PowerShell/Win32-OpenSSH/issues/566 --- contrib/win32/win32compat/shell-host.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/contrib/win32/win32compat/shell-host.c b/contrib/win32/win32compat/shell-host.c index de8ae2f32..7b1fd95d3 100644 --- a/contrib/win32/win32compat/shell-host.c +++ b/contrib/win32/win32compat/shell-host.c @@ -1205,8 +1205,14 @@ wmain(int ac, wchar_t **av) char *cmd_b64_utf8, *cmd_utf8; if ((cmd_b64_utf8 = utf16_to_utf8(cmd_b64)) == NULL || /* strlen(b64) should be sufficient for decoded length */ - (cmd_utf8 = malloc(strlen(cmd_b64_utf8))) == NULL || - b64_pton(cmd_b64_utf8, cmd_utf8, strlen(cmd_b64_utf8)) == -1 || + (cmd_utf8 = malloc(strlen(cmd_b64_utf8))) == NULL) { + printf("ssh-shellhost - out of memory"); + return -1; + } + + memset(cmd_utf8, 0, strlen(cmd_b64_utf8)); + + if (b64_pton(cmd_b64_utf8, cmd_utf8, strlen(cmd_b64_utf8)) == -1 || (cmd = utf8_to_utf16(cmd_utf8)) == NULL) { printf("ssh-shellhost encountered an internal error while decoding base64 cmdline"); return -1;