Skip to content

The inet_ntop() function returns an IPv6 string for the string "April Fool's Day" #19749

@MisterVector

Description

@MisterVector

Description

The following code:

<?php
    $ip = "April Fool's Day";
    
    echo inet_ntop($ip) !== false ? "Valid IP!" : "Invalid IP!";

Resulted in this output:

Valid IP!

But I expected this output instead:

Invalid IP!

The length of the $ip variable is 16 characters, which would equal a packed IPv6 address, however it is an invalid address given that some characters are not in the hexadecimal range.

PHP Version

Tested using PHP 8.3.21, 8.4.10, 8.2.29 and 8.1.33 from https://onlinephp.io/

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions