aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2018-09-04 10:30:09 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-09-05 11:43:05 +0200
commit9f5f10552b54d1e8a21f9ccbcf5bbe37744d36f6 (patch)
tree8c6c4068d9b6167d0e004fd5bf3631231bc424b3 /src
parent458bda88779c2e10094bc49331d368de4b9c6044 (diff)
downloadlibssh-9f5f10552b54d1e8a21f9ccbcf5bbe37744d36f6.tar.gz
libssh-9f5f10552b54d1e8a21f9ccbcf5bbe37744d36f6.tar.xz
libssh-9f5f10552b54d1e8a21f9ccbcf5bbe37744d36f6.zip
config: Do not overwrite previously matched result in Host blocks
The match_hostname() expects comma separated list, while the Host config keyword in openssh uses spaces separated list by default. Therefore any subseqent match or negated match in space separated list will overwrite the previous matches. This also adjusts the tests to make sure both of the versions work. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src')
-rw-r--r--src/config.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/config.c b/src/config.c
index 6435f860..5d1baa51 100644
--- a/src/config.c
+++ b/src/config.c
@@ -406,7 +406,7 @@ static int ssh_config_parse_line(ssh_session session, const char *line,
}
break;
case SOC_HOST: {
- int ok = 0;
+ int ok = 0, result = -1;
*parsing = 0;
lowerhost = (session->opts.host) ? ssh_lowercase(session->opts.host) : NULL;
@@ -415,14 +415,17 @@ static int ssh_config_parse_line(ssh_session session, const char *line,
p = ssh_config_get_str_tok(&s, NULL)) {
if (ok >= 0) {
ok = match_hostname(lowerhost, p, strlen(p));
- if (ok < 0) {
- *parsing = 0;
- } else if (ok > 0) {
- *parsing = 1;
+ if (result == -1 && ok < 0) {
+ result = 0;
+ } else if (result == -1 && ok > 0) {
+ result = 1;
}
}
}
SAFE_FREE(lowerhost);
+ if (result != -1) {
+ *parsing = result;
+ }
break;
}
case SOC_HOSTNAME: