From: Michael Poole Date: Tue, 21 Aug 2007 02:02:10 +0000 (+0000) Subject: Match 127.*.*.* masks against IPs in the usually expected manner. X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=eeebbe9bf464ee89dbc12568cae4cc4be8ca836d Match 127.*.*.* masks against IPs in the usually expected manner. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1834 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index fe17670..303bead 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-08-20 Michael Poole + + * ircd/ircd_string.c (ircd_aton_ip4): Allow a sequence of *.* at + the end of an IPv4 mask. + (ipmask_parse): Likewise for *:* at the end of IPv6 masks. + + * ircd/test/ircd_in_addr_t.c (test_masks): Add tests for this. + 2007-08-20 Michael Poole * ircd/s_user.c (register_user): Update inv_clients and opers diff --git a/ircd/ircd_string.c b/ircd/ircd_string.c index a9d9451..1ed082d 100644 --- a/ircd/ircd_string.c +++ b/ircd/ircd_string.c @@ -486,7 +486,7 @@ ircd_aton_ip4(const char *input, unsigned int *output, unsigned char *pbits) ip |= part << (24 - 8 * dots++); part = 0; if (input[pos] == '*') { - while (input[++pos] == '*') ; + while (input[++pos] == '*' || input[pos] == '.') ; if (input[pos] != '\0') return 0; if (pbits) @@ -604,7 +604,7 @@ ipmask_parse(const char *input, struct irc_in_addr *ip, unsigned char *pbits) *pbits = part; goto finish; case '*': - while (input[++pos] == '*') ; + while (input[++pos] == '*' || input[pos] == ':') ; if (input[pos] != '\0' || colon < 8) return 0; if (pbits) diff --git a/ircd/test/ircd_in_addr_t.c b/ircd/test/ircd_in_addr_t.c index 07f6cc9..1a65aec 100644 --- a/ircd/test/ircd_in_addr_t.c +++ b/ircd/test/ircd_in_addr_t.c @@ -111,6 +111,7 @@ static struct ipmask_test test_masks[] = { { "::10.0.0.0", {{ 0, 0, 0, 0, 0, 0, 0xa00, 0 }}, 1, 1, 128 }, { "192.168/16", {{ 0, 0, 0, 0, 0, 0xffff, 0xc0a8, 0 }}, 1, 1, 112 }, { "192.*", {{ 0, 0, 0, 0, 0, 0xffff, 0xc000, 0 }}, 1, 1, 104 }, + { "192.*.*.*", {{ 0, 0, 0, 0, 0, 0xffff, 0xc000, 0 }}, 1, 1, 104 }, { "192.*/8", {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 1, 0, 0 }, { "192*", {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 1, 0, 0 }, { "192.168.0.0/16", {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 0, 0, 0 }, @@ -120,6 +121,7 @@ static struct ipmask_test test_masks[] = { { "a:b", {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 1, 0, 0 }, { "a::*", {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 1, 0, 0 }, { "a:*", {{ 0xa, 0, 0, 0, 0, 0, 0, 0 }}, 1, 1, 16 }, + { "a:*:*", {{ 0xa, 0, 0, 0, 0, 0, 0, 0 }}, 1, 1, 16 }, { "a:/16", {{ 0xa, 0, 0, 0, 0, 0, 0, 0 }}, 1, 1, 16 }, { 0 } };