Skip to content

integer overflow in logical_filters.c:825:14 #18310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chongwick opened this issue Apr 11, 2025 · 1 comment
Closed

integer overflow in logical_filters.c:825:14 #18310

chongwick opened this issue Apr 11, 2025 · 1 comment

Comments

@chongwick
Copy link

Description

The following code:

<?php
$ipv6_test = array();

for ($i = 0; $i < 100000; $i++) {
    $ip = '0:'. str_repeat('0', 15 - strlen(bin2hex(random_bytes(6)))). ':'. bin2hex(random_bytes(2)). ':'. bin2hex(random_bytes(2)). ':'. bin2hex(random_bytes(2)). ':'. bin2hex(random_bytes(2)). ':'. bin2hex(random_bytes(4));
    $ipv6_test[$ip] = true;
}

foreach ($ipv6_test as $ip => $exp) {
    $out = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
    $out = $out!== false;
    if ($exp!= $out) {
        echo "$ip failed (expected ", $exp?"true":"false", ", got ",
            $out?"true":"false", ")\n";
    }
}

?>

Resulted in this output:

/nightly_php/php-src/ext/filter/logical_filters.c:825:14: runtime error: signed integer overflow: 208068286 * 16 cannot be represented in type 'int'

PHP Version

nightly

Operating System

ubuntu 22.04

@nielsdos
Copy link
Member

Duplicate of #18309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants