aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravers Carter <tcarter@noggin.com.au>2015-04-12 22:33:06 +1000
committerAndreas Schneider <asn@cryptomilk.org>2016-05-03 17:57:12 +0200
commitbc2db86d1c8a974cdfa412f9f6c250893ed9a66c (patch)
treeff8520bc02c6ed4b18f6656b0c92e1078d84532d
parent2fe9c2e3521008a0ceb38e2c1c7360a76fe85523 (diff)
downloadlibssh-bc2db86d1c8a974cdfa412f9f6c250893ed9a66c.tar.gz
libssh-bc2db86d1c8a974cdfa412f9f6c250893ed9a66c.tar.xz
libssh-bc2db86d1c8a974cdfa412f9f6c250893ed9a66c.zip
Make "Host" pattern list handling consistent with OpenSSH
https://red.libssh.org/issues/187 Signed-off-by: Travers Carter <tcarter@noggin.com.au> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/config.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/config.c b/src/config.c
index 0d44c215..edbaf80c 100644
--- a/src/config.c
+++ b/src/config.c
@@ -221,20 +221,24 @@ static int ssh_config_parse_line(ssh_session session, const char *line,
case SOC_HOST:
*parsing = 0;
lowerhost = (session->opts.host) ? ssh_lowercase(session->opts.host) : NULL;
+ int ok = 0;
for (p = ssh_config_get_str_tok(&s, NULL);
p != NULL && p[0] != '\0';
p = ssh_config_get_str_tok(&s, NULL)) {
- char *z = ssh_path_expand_escape(session, p);
- int ok;
-
- if (z == NULL) {
- z = strdup(p);
- }
- ok = match_hostname(lowerhost, z, strlen(z));
- if (ok) {
- *parsing = 1;
+ if (ok >= 0) {
+ char *z = ssh_path_expand_escape(session, p);
+
+ if (z == NULL) {
+ z = strdup(p);
+ }
+ ok = match_hostname(lowerhost, z, strlen(z));
+ if (ok < 0) {
+ *parsing = 0;
+ } else if (ok > 0) {
+ *parsing = 1;
+ }
+ free(z);
}
- free(z);
}
SAFE_FREE(lowerhost);
break;