php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75431 False negative filtering a string with short IPv4
Submitted: 2017-10-24 17:50 UTC Modified: 2017-10-24 22:40 UTC
From: skv at eml dot ru Assigned:
Status: Not a bug Package: Filter related
PHP Version: Irrelevant OS: linux (debian/ubuntu)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: skv at eml dot ru
New email:
PHP Version: OS:

 

 [2017-10-24 17:50 UTC] skv at eml dot ru
Description:
------------
---
From manual page: http://www.php.net/filter.filters.validate
---

The FILTER_VALIDATE_IP ignores short notations of IPv4 address (e.g. "127.1") and falsely reports them to not be valid IP Addresses.
It somehow manages to recognize short forms of IPv6 addresses though (e.g. "::1").

Btw, simple telnet manages to recognize 'em:
$ telnet 127.1 22
Trying 127.0.0.1...
Connected to 127.1.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2

Test script:
---------------
#!/bin/bash

php -r 'var_dump( filter_var("127.1", FILTER_VALIDATE_IP) );'

Expected result:
----------------
string(5) "127.1"

Actual result:
--------------
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-24 22:40 UTC] kalle@php.net
-Status: Open +Status: Not a bug
 [2017-10-24 22:40 UTC] kalle@php.net
The ext/filter extension conforms RFC791 which does not specify any short notation. You may want to consider using the inet_*() family functions for non standardized conversions.

Thanks!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 19:01:31 2024 UTC