Skip to content

overflow in tm2unixtime.c:39:16 #17036

@chongwick

Description

@chongwick

Description

The following code:

<?php

class ArrayLike {
    private $num;
    public function __construct($num) {
        $this->num = $num;
    }
    public function __get($name) {
        if ($name == 0) {
            return PHP_INT_MAX;
        } elseif ($name == 1) {
            return PHP_INT_MIN;
        } elseif ($name == 2) {
            return PHP_FLOAT_MAX;
        } elseif ($name == 3) {
            return PHP_FLOAT_MIN;
        }
        return null;
    }
}

$arrayLike = new ArrayLike(0);
$arrayLike->{(int)PHP_INT_MAX};

$date = mktime($arrayLike->{(int)PHP_INT_MAX}, $arrayLike->{(int)PHP_INT_MIN}, $arrayLike->{(int)PHP_FLOAT_MAX}, PHP_INT_MIN, PHP_INT_MIN, PHP_INT_MIN);
$result = checkdate(2, 3, $date);
return $result;

echo $result;

?>

Resulted in this output:

/home/dan/php-src/ext/date/lib/tm2unixtime.c:39:16: runtime error: signed integer overflow: 1 - -9223372036854775807 cannot be represented in type 'long long int'

But I expected this output instead:

PHP Version

8.4.1

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions