From 520591607e3f7fbc639f7868c843485b612dbf5f Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Thu, 16 Jul 2009 23:29:36 +0000 Subject: [PATCH] - MFH: Fixed bug #48762 (IPv6 address filter still rejects valid address) --- ext/filter/logical_filters.c | 11 ++++------- ext/filter/tests/bug48762.phpt | 12 ++++++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 ext/filter/tests/bug48762.phpt diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 555a3f914f..bf3eaff107 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -529,7 +529,7 @@ static int _php_filter_validate_ipv6(char *str, int str_len TSRMLS_DC) /* {{{ */ int compressed = 0; int blocks = 8; int n; - char *ipv4 = NULL; + char *ipv4; char *end; int ip4elm[4]; char *s = str; @@ -555,24 +555,21 @@ static int _php_filter_validate_ipv6(char *str, int str_len TSRMLS_DC) /* {{{ */ blocks = 6; } - end = ipv4 ? ipv4 : str + str_len; + end = str + str_len; while (str < end) { if (*str == ':') { if (--blocks == 0) { - if ((str+1) == end && ipv4) { - return 1; - } return 0; } if (++str >= end) { - return (ipv4 && ipv4 == str && blocks == 3) || 0; + return 0; } if (*str == ':') { if (compressed || --blocks == 0) { return 0; } - if (++str == end || (ipv4 && ipv4 == str)) { + if (++str == end) { return 1; } compressed = 1; diff --git a/ext/filter/tests/bug48762.phpt b/ext/filter/tests/bug48762.phpt new file mode 100644 index 0000000000..1737f0a75e --- /dev/null +++ b/ext/filter/tests/bug48762.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #48762 (IPv6 address filter still rejects valid address) +--FILE-- + +--EXPECT-- +string(23) "0b15:23::3:67.98.234.17" +string(19) "::67:78b:34.43.43.2" -- 2.40.0