From 61ba998eecf75f56f8a677d5150fe8b5036a0bcb Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 15 Nov 2004 19:38:31 +0000 Subject: [PATCH] Make hostname_matches() return TRUE for a match, else FALSE like the caller expects. --- match.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/match.c b/match.c index c3ddc0fd8..93849b18e 100644 --- a/match.c +++ b/match.c @@ -195,7 +195,7 @@ host_matches(shost, lhost, list) switch (m->type) { case ALIAS: rval = alias_matches(m->name, HOSTALIAS, shost, lhost); - if (rval != UNSPEC || hostname_matches(shost, lhost, m->name)) + if (rval != UNSPEC || (rval = hostname_matches(shost, lhost, m->name))) matched = rval; break; case ALL: @@ -483,7 +483,7 @@ addr_matches(n) } /* - * Returns 0 if the hostname matches the pattern and non-zero otherwise. + * Returns TRUE if the hostname matches the pattern, else FALSE */ int hostname_matches(shost, lhost, pattern) @@ -493,14 +493,14 @@ hostname_matches(shost, lhost, pattern) { if (has_meta(pattern)) { if (strchr(pattern, '.')) - return(fnmatch(pattern, lhost, FNM_CASEFOLD)); + return(!fnmatch(pattern, lhost, FNM_CASEFOLD)); else - return(fnmatch(pattern, shost, FNM_CASEFOLD)); + return(!fnmatch(pattern, shost, FNM_CASEFOLD)); } else { if (strchr(pattern, '.')) - return(strcasecmp(lhost, pattern)); + return(!strcasecmp(lhost, pattern)); else - return(strcasecmp(shost, pattern)); + return(!strcasecmp(shost, pattern)); } } -- 2.40.0