From 8a037e9afe0d42bb65664493a37a1e08f283f3d1 Mon Sep 17 00:00:00 2001 From: Ran Park Date: Mon, 17 Apr 2023 19:57:37 +0800 Subject: [PATCH] solve incorrect parsing of the ProxyCommand configuration option Signed-off-by: Ran Park Reviewed-by: Jakub Jelen (cherry picked from commit 9cd23fecacf9efeb42290a3cb955e1d84d49343a) --- src/config_parser.c | 13 ++----------- src/socket.c | 7 ++++++- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/config_parser.c b/src/config_parser.c index 2f91d39f..0d988fec 100644 --- a/src/config_parser.c +++ b/src/config_parser.c @@ -32,7 +32,7 @@ #include "libssh/priv.h" /* Returns the original string after skipping the leading whitespace - * and optional quotes. + * until finding LF. * This is useful in case we need to get the rest of the line (for example * external command). */ @@ -47,16 +47,7 @@ char *ssh_config_get_cmd(char **str) break; } } - - if (*c == '\"') { - for (r = ++c; *c; c++) { - if (*c == '\"') { - *c = '\0'; - goto out; - } - } - } - + for (r = c; *c; c++) { if (*c == '\n') { *c = '\0'; diff --git a/src/socket.c b/src/socket.c index 4580652d..0a6e4982 100644 --- a/src/socket.c +++ b/src/socket.c @@ -925,7 +925,12 @@ ssh_execute_command(const char *command, socket_t in, socket_t out) if (shell == NULL || shell[0] == '\0') { /* Fall back to bash. There are issues with dash or * whatever people tend to link to /bin/sh */ - shell = "/bin/bash"; + rc = access("/bin/bash", 0); + if (rc != 0) { + shell = "/bin/sh"; + } else { + shell = "/bin/bash"; + } } args[0] = shell;