From da0b80c46f34268a34c3eed8229e19bd7e289af2 Mon Sep 17 00:00:00 2001 From: ago-shi Date: Mon, 22 Aug 2022 00:09:00 +0900 Subject: [PATCH] Fix not to assign null to strstr function --- contrib/win32/win32compat/w32-doexec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/contrib/win32/win32compat/w32-doexec.c b/contrib/win32/win32compat/w32-doexec.c index 64c49d698..ad27fcd64 100644 --- a/contrib/win32/win32compat/w32-doexec.c +++ b/contrib/win32/win32compat/w32-doexec.c @@ -469,12 +469,15 @@ int do_exec_windows(struct ssh *ssh, Session *s, const char *command, int pty) { } //Passing the PRIVSEP_LOG_FD (STDERR_FILENO + 2) to sftp-server for logging - if(strstr(exec_command, "sftp-server.exe")) - if (posix_spawn_file_actions_adddup2(&actions, STDERR_FILENO + 2, SFTP_SERVER_LOG_FD) != 0) { - errno = EOTHER; - error("posix_spawn initialization failed"); - goto cleanup; + if (command) { + if (strstr(exec_command, "sftp-server.exe")) { + if (posix_spawn_file_actions_adddup2(&actions, STDERR_FILENO + 2, SFTP_SERVER_LOG_FD) != 0) { + errno = EOTHER; + error("posix_spawn initialization failed"); + goto cleanup; + } } + } if (posix_spawn(&pid, spawn_argv[0], &actions, NULL, spawn_argv, NULL) != 0) { errno = EOTHER;