php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79906 FILTER_FLAG_NO_RES_RANGE wrong on short IPv6 addresses
Submitted: 2020-07-28 12:05 UTC Modified: 2021-08-05 15:58 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: os at tnys-welt dot de Assigned: cmb (profile)
Status: Duplicate Package: Filter related
PHP Version: 7.4.8 OS: all
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: os at tnys-welt dot de
New email:
PHP Version: OS:

 

 [2020-07-28 12:05 UTC] os at tnys-welt dot de
Description:
------------
The flag FILTER_FLAG_NO_RES_RANGE for IPv6 is working internally with strncasecmp and does not take into account, that IPv6 addresses may be shortened by removing leading zeros.

line 900ff of ext/filter/logical_filters.c:
(Z_STRLEN_P(value) >= 9 &&  !strncasecmp("2001:0db8", Z_STRVAL_P(value), 9)) ||
(Z_STRLEN_P(value) >= 2 &&  !strncasecmp("5f", Z_STRVAL_P(value), 2)) ||
(Z_STRLEN_P(value) >= 4 &&  !strncasecmp("3ff3", Z_STRVAL_P(value), 4)) ||
(Z_STRLEN_P(value) >= 8 &&  !strncasecmp("2001:001", Z_STRVAL_P(value), 8))

Test script:
---------------
<?php

var_dump(filter_var('2001:0db8:0000:08d3:0000:8a2e:0070:7344', FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
var_dump(filter_var('2001:db8:0:8d3:0:8a2e:70:7344', FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));

Expected result:
----------------
bool(false)
bool(false)

Actual result:
--------------
bool(false)
string(29) "2001:db8:0:8d3:0:8a2e:70:7344"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-05 15:58 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Package: Unknown/Other Function +Package: Filter related -Assigned To: +Assigned To: cmb
 [2021-08-05 15:58 UTC] cmb@php.net
This is basically a duplicate of bug #61700.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC