]> granicus.if.org Git - php/commitdiff
Fix #72972, Bad filter for the flags FILTER_FLAG_NO_RES_RANGE and FILTER_FLAG_NO_PRIV...
authorJulien Pauli <jpauli@php.net>
Thu, 1 Sep 2016 08:36:58 +0000 (10:36 +0200)
committerJulien Pauli <jpauli@php.net>
Mon, 5 Sep 2016 08:08:42 +0000 (10:08 +0200)
ext/filter/logical_filters.c
ext/filter/tests/018.phpt
ext/filter/tests/filter_ipv4_rfc6890.phpt

index 521fb50a3a6cdc2f8cc2d6988351c5ee068ac726..39a035f3aff7e5eb063b403204fb05c2f338da8e 100644 (file)
@@ -704,8 +704,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
                        if (flags & FILTER_FLAG_NO_PRIV_RANGE) {
                                if (
                                        (ip[0] == 10) ||
-                                       (ip[0] == 169 && ip[1] == 254) ||
-                                       (ip[0] == 172 && (ip[1] >= 16 && ip[1] <= 31)) ||
+                                       (ip[0] == 172 && ip[1] >= 16 && ip[1] <= 31) ||
                                        (ip[0] == 192 && ip[1] == 168)
                                ) {
                                        RETURN_VALIDATION_FAILED
@@ -715,19 +714,9 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
                        if (flags & FILTER_FLAG_NO_RES_RANGE) {
                                if (
                                        (ip[0] == 0) ||
-                                       (ip[0] == 10) ||
-                                       (ip[0] == 100 && (ip[1] >= 64 && ip[1] <= 127)) ||
+                                       (ip[0] >= 240) ||
                                        (ip[0] == 127) ||
-                                       (ip[0] == 169 && ip[1] == 254) ||
-                                       (ip[0] == 172 && (ip[1] >= 16 && ip[1] <= 31)) ||
-                                       (ip[0] == 192 && ip[1] == 0 && ip[2] == 0) ||
-                                       (ip[0] == 192 && ip[1] == 0 && ip[2] == 2) ||
-                                       (ip[0] == 192 && ip[1] == 88 && ip[2] == 99) ||
-                                       (ip[0] == 192 && ip[1] == 168) ||
-                                       (ip[0] == 198 && (ip[1] == 18 || ip[1] == 19)) ||
-                                       (ip[0] == 198 && ip[1] == 51 && ip[2] == 100) ||
-                                       (ip[0] == 203 && ip[1] == 0 && ip[2] == 113) ||
-                                       (ip[0] >= 224 && ip[0] <= 255)
+                                       (ip[0] == 169 && ip[1] == 254)
                                ) {
                                        RETURN_VALIDATION_FAILED
                                }
index 11d7fc64efef6fead38d3b5fd2819f290a171408..833500fd3382d85145130e5b44c19aebd2845f49 100644 (file)
@@ -41,9 +41,9 @@ string(9) "127.0.0.1"
 bool(false)
 string(12) "192.0.34.166"
 bool(false)
-bool(false)
-bool(false)
-bool(false)
+string(9) "192.0.0.1"
+string(10) "100.64.0.0"
+string(15) "100.127.255.255"
 string(12) "192.0.34.166"
 bool(false)
 string(15) "255.255.255.255"
index cfd9f8dc0773a0b19cc9930df9833c8e05bc3ce7..b1920c762d71c610f198c317f28b4f5da38160a6 100644 (file)
@@ -85,8 +85,8 @@ string(10) "10.0.0.0/8"
 bool(false)
 bool(false)
 string(14) "168.254.0.0/16"
-bool(false)
-bool(false)
+string(11) "169.254.0.0"
+string(15) "169.254.255.255"
 string(13) "172.16.0.0/12"
 bool(false)
 bool(false)
@@ -94,11 +94,11 @@ string(14) "192.168.0.0/16"
 bool(false)
 bool(false)
 string(10) "10.0.0.0/8"
-bool(false)
-bool(false)
+string(8) "10.0.0.0"
+string(14) "10.255.255.255"
 string(12) "10.64.0.0/10"
-bool(false)
-bool(false)
+string(10) "100.64.0.0"
+string(15) "100.127.255.255"
 string(11) "127.0.0.0/8"
 bool(false)
 bool(false)
@@ -106,32 +106,32 @@ string(14) "169.254.0.0/16"
 bool(false)
 bool(false)
 string(13) "172.16.0.0/12"
-bool(false)
-bool(false)
+string(10) "172.16.0.0"
+string(10) "172.31.0.0"
 string(12) "192.0.0.0/24"
-bool(false)
-bool(false)
+string(9) "192.0.0.0"
+string(11) "192.0.0.255"
 string(12) "192.0.0.0/29"
-bool(false)
-bool(false)
+string(9) "192.0.0.0"
+string(9) "192.0.0.7"
 string(12) "192.0.2.0/24"
-bool(false)
-bool(false)
+string(9) "192.0.2.0"
+string(11) "192.0.2.255"
 string(13) "198.18.0.0/15"
-bool(false)
-bool(false)
+string(10) "198.18.0.0"
+string(14) "198.19.255.255"
 string(15) "198.51.100.0/24"
-bool(false)
-bool(false)
+string(12) "198.51.100.0"
+string(14) "198.51.100.255"
 string(14) "192.88.99.0/24"
-bool(false)
-bool(false)
+string(11) "192.88.99.0"
+string(13) "192.88.99.255"
 string(14) "192.168.0.0/16"
-bool(false)
-bool(false)
+string(11) "192.168.0.0"
+string(15) "192.168.255.255"
 string(14) "203.0.113.0/24"
-bool(false)
-bool(false)
+string(11) "203.0.113.0"
+string(13) "203.0.113.255"
 string(11) "240.0.0.0/4"
-bool(false)
+string(9) "224.0.0.0"
 bool(false)