|  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
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 Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: os at tnys-welt dot de
New email:
PHP Version: OS:


 [2020-07-28 12:05 UTC] os at tnys-welt dot de
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:

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:

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-05 15:58 UTC]
-Status: Open +Status: Duplicate -Package: Unknown/Other Function +Package: Filter related -Assigned To: +Assigned To: cmb
 [2021-08-05 15:58 UTC]
This is basically a duplicate of bug #61700.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Mar 25 05:04:10 2023 UTC