Bug #79906 [Opn->Dup]: FILTER_FLAG_NO_RES_RANGE wrong on short IPv6 addresses

From: Date: Thu, 05 Aug 2021 15:58:16 +0000
Subject: Bug #79906 [Opn->Dup]: FILTER_FLAG_NO_RES_RANGE wrong on short IPv6 addresses
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235616@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79906&edit=1 ID: 79906 Updated by: cmb@php.net Reported by: os at tnys-welt dot de Summary: FILTER_FLAG_NO_RES_RANGE wrong on short IPv6 addresses -Status: Open +Status: Duplicate Type: Bug -Package: Unknown/Other Function +Package: Filter related Operating System: all PHP Version: 7.4.8 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This is basically a duplicate of bug #61700. Previous Comments: ------------------------------------------------------------------------ [2020-07-28 12:05:10] 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" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79906&edit=1

« previous php.bugs (#235616) next »