Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpFoundation] IpUtils::checkIp4 incorrectly handles CIDR notation with subnet 0.0.0.0/0 #16055

Closed
@ultrafez

Description

@ultrafez

The checkIp4 method in IpUtils is able to check whether an IP belongs to a particular subnet specified in CIDR notation, however it incorrectly states that all IP addresses are not members of the subnet 0.0.0.0/0.

This is due to the check on the size of the netmask in IpUtils::checkIp4 - if the netmask is less than -1, then it immediately returns false, which is incorrect - all IPv4 addresses are members of the /0 subnet by default.

This can easily be fixed by adding a check for whether $netmask === 0, and if so, returning true immediately, since all IPs would be a member.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions