From c1b89eba62707ffc6f6daf8e818036dec3dfbc2a Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Mon, 22 Nov 2010 07:33:45 -0500 Subject: [PATCH] Update IP glob matching to work more accurately with IPv6. When given an IP like 2001::1234:5678:1:2:3:4, srvx (properly) makes a glob like 2001:0:4137:*. However, it wouldn't realize that the glob actually matches the IP, because it used string glob matching. src/tools.c (user_matches_glob): Use a parsed glob to match against the user's IP address. --- src/tools.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tools.c b/src/tools.c index 7ba3738..b10bc7b 100644 --- a/src/tools.c +++ b/src/tools.c @@ -591,7 +591,9 @@ extern const char *hidden_host_suffix; int user_matches_glob(struct userNode *user, const char *orig_glob, int flags) { + irc_in_addr_t mask; char *glob, *marker; + unsigned char mask_bits; /* Make a writable copy of the glob */ glob = alloca(strlen(orig_glob)+1); @@ -631,8 +633,8 @@ user_matches_glob(struct userNode *user, const char *orig_glob, int flags) && (IsFakeHost(user) || (hidden_host_suffix && user->handle_info))) return 0; /* If it might be an IP glob, test that. */ - if (!glob[strspn(glob, "0123456789./*?")] - && match_ircglob(irc_ntoa(&user->ip), glob)) + if (irc_pton(&mask, &mask_bits, glob) + && irc_check_mask(&user->ip, &mask, mask_bits)) return 1; /* None of the above; could only be a hostname match. */ return match_ircglob(user->hostname, glob); -- 2.20.1