From 04846fe0848d04de677abbb0c9ff8b46c68b0807 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Sat, 16 Oct 2004 21:14:11 +0000 Subject: [PATCH] Fix glob matching against IPs Do not require the first character in an IP glob to be a digit. If an IP-looking glob does not match, fall through to the other host matching rules, in case the IP-looking glob really matches their hostname. git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-82 --- ChangeLog | 15 +++++++++++++++ src/tools.c | 28 ++++++++++++++-------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d9f114..b577fd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,21 @@ # arch-tag: automatic-ChangeLog--srvx@srvx.net--2004-srvx/srvx--devo--1.3 # +2004-10-16 21:14:11 GMT Michael Poole patch-82 + + Summary: + Fix glob matching against IPs + Revision: + srvx--devo--1.3--patch-82 + + Do not require the first character in an IP glob to be a digit. If an + IP-looking glob does not match, fall through to the other host matching + rules, in case the IP-looking glob really matches their hostname. + + modified files: + ChangeLog src/tools.c + + 2004-09-15 04:14:14 GMT adam patch-81 Summary: diff --git a/src/tools.c b/src/tools.c index 53214dc..26c83a9 100644 --- a/src/tools.c +++ b/src/tools.c @@ -334,22 +334,22 @@ user_matches_glob(struct userNode *user, const char *orig_glob, int include_nick if (!match_ircglob(user->ident, glob)) return 0; glob = marker + 1; - /* Now check the host part */ - if (isdigit(*glob) && !glob[strspn(glob, "0123456789./*?")]) { - /* Looks like an IP-based mask */ - return match_ircglob(inet_ntoa(user->ip), glob); - } else { - /* The host part of the mask isn't IP-based */ - if (IsFakeHost(user) && match_ircglob(user->fakehost, glob)) + /* If it might be an IP glob, test that. */ + if (!glob[strspn(glob, "0123456789./*?")] + && match_ircglob(inet_ntoa(user->ip), glob)) + return 1; + /* Check for a fakehost match. */ + if (IsFakeHost(user) && match_ircglob(user->fakehost, glob)) + return 1; + /* Check for an account match. */ + if (hidden_host_suffix && user->handle_info) { + char hidden_host[HOSTLEN+1]; + snprintf(hidden_host, sizeof(hidden_host), "%s.%s", user->handle_info->handle, hidden_host_suffix); + if (match_ircglob(hidden_host, glob)) return 1; - if (hidden_host_suffix && user->handle_info) { - char hidden_host[HOSTLEN+1]; - snprintf(hidden_host, sizeof(hidden_host), "%s.%s", user->handle_info->handle, hidden_host_suffix); - if (match_ircglob(hidden_host, glob)) - return 1; - } - return match_ircglob(user->hostname, glob); } + /* None of the above; could only be a hostname match. */ + return match_ircglob(user->hostname, glob); } int -- 2.20.1