Skip to content

Commit a16ee2f

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 5191581 + 118ed09 commit a16ee2f

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

ext/filter/logical_filters.c

+23-22
Original file line numberDiff line numberDiff line change
@@ -925,13 +925,13 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
925925

926926
if (flags & FILTER_FLAG_GLOBAL_RANGE) {
927927
if (
928-
(ip[0] == 100 && ip[1] >= 64 && ip[1] <= 127 ) ||
929-
(ip[0] == 192 && ip[1] == 0 && ip[2] == 0 ) ||
930-
(ip[0] == 192 && ip[1] == 0 && ip[2] == 2 ) ||
931-
(ip[0] == 198 && ip[1] >= 18 && ip[1] <= 19 ) ||
932-
(ip[0] == 198 && ip[1] == 51 && ip[2] == 100 ) ||
933-
(ip[0] == 203 && ip[1] == 0 && ip[2] == 113 )
934-
) {
928+
(ip[0] == 100 && ip[1] >= 64 && ip[1] <= 127 ) ||
929+
(ip[0] == 192 && ip[1] == 0 && ip[2] == 0 ) ||
930+
(ip[0] == 192 && ip[1] == 0 && ip[2] == 2 ) ||
931+
(ip[0] == 198 && ip[1] >= 18 && ip[1] <= 19 ) ||
932+
(ip[0] == 198 && ip[1] == 51 && ip[2] == 100 ) ||
933+
(ip[0] == 203 && ip[1] == 0 && ip[2] == 113 )
934+
) {
935935
RETURN_VALIDATION_FAILED
936936
}
937937
}
@@ -952,23 +952,24 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
952952
}
953953
}
954954
if (flags & FILTER_FLAG_NO_RES_RANGE || flags & FILTER_FLAG_GLOBAL_RANGE) {
955-
if ((ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0
956-
&& ip[4] == 0 && ip[5] == 0 && ip[6] == 0 && (ip[7] == 0 || ip[7] == 1))
957-
|| (ip[0] == 0x5f)
958-
|| (ip[0] >= 0xfe80 && ip[0] <= 0xfebf)
959-
|| (ip[0] == 0x2001 && (ip[1] == 0x0db8 || (ip[1] >= 0x0010 && ip[1] <= 0x001f)))
960-
|| (ip[0] == 0x3ff3)
961-
) {
962-
RETURN_VALIDATION_FAILED
963-
}
955+
if (
956+
(ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0 && ip[4] == 0 && ip[5] == 0 && ip[6] == 0 && (ip[7] == 0 || ip[7] == 1)) ||
957+
(ip[0] == 0x5f) ||
958+
(ip[0] >= 0xfe80 && ip[0] <= 0xfebf) ||
959+
(ip[0] == 0x2001 && (ip[1] == 0x0db8 || (ip[1] >= 0x0010 && ip[1] <= 0x001f))) ||
960+
(ip[0] == 0x3ff3)
961+
) {
962+
RETURN_VALIDATION_FAILED
963+
}
964964
}
965965
if (flags & FILTER_FLAG_GLOBAL_RANGE) {
966-
if ((ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0 && ip[4] == 0 && ip[5] == 0xffff) ||
967-
(ip[0] == 0x0100 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0) ||
968-
(ip[0] == 0x2001 && ip[1] <= 0x01ff) ||
969-
(ip[0] == 0x2001 && ip[1] == 0x0002 && ip[2] == 0) ||
970-
(ip[0] >= 0xfc00 && ip[0] <= 0xfdff)
971-
) {
966+
if (
967+
(ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0 && ip[4] == 0 && ip[5] == 0xffff) ||
968+
(ip[0] == 0x0100 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0) ||
969+
(ip[0] == 0x2001 && ip[1] <= 0x01ff) ||
970+
(ip[0] == 0x2001 && ip[1] == 0x0002 && ip[2] == 0) ||
971+
(ip[0] >= 0xfc00 && ip[0] <= 0xfdff)
972+
) {
972973
RETURN_VALIDATION_FAILED
973974
}
974975
}

0 commit comments

Comments
 (0)