Skip to content

Commit 9d1deb9

Browse files
committed
Include changes from RFC 6890 errata
1 parent d25aac2 commit 9d1deb9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ext/filter/logical_filters.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,14 +869,18 @@ static int _php_filter_validate_ipv6(const char *str, size_t str_len, int ip[8])
869869
}
870870
/* }}} */
871871

872-
/* From the tables in RFC 6890 - Special-Purpose IP Address Registries */
872+
/* From the tables in RFC 6890 - Special-Purpose IP Address Registriesi
873+
* Including errata: https://www.rfc-editor.org/errata_search.php?rfc=6890&rec_status=1 */
873874
static bool ipv4_get_status_flags(const int ip[8], bool *global, bool *reserved, bool *private)
874875
{
875876
*global = false;
876877
*reserved = false;
877878
*private = false;
878879

879880
if (ip[0] == 0) {
881+
/* RFC 0791 - This network */
882+
*reserved = true;
883+
} else if (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0) {
880884
/* RFC 1122 - This host on this network */
881885
*reserved = true;
882886
} else if (ip[0] == 10) {
@@ -915,7 +919,8 @@ static bool ipv4_get_status_flags(const int ip[8], bool *global, bool *reserved,
915919
/* RFC 1122 - Reserved */
916920
*reserved = true;
917921
} else if (ip[0] == 255 && ip[1] == 255 && ip[2] == 255 && ip[3] == 255) {
918-
/* RFC 0919 - Limited Broadcast */
922+
/* RFC 0919 - Limited Broadcast, Updated by RFC 8190, 2.2. */
923+
*reserved = true;
919924
} else {
920925
return false;
921926
}

0 commit comments

Comments
 (0)