Skip to content

int overflow in Date extension #18422

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

Open
chongwick opened this issue Apr 24, 2025 · 1 comment
Open

int overflow in Date extension #18422

chongwick opened this issue Apr 24, 2025 · 1 comment

Comments

@chongwick
Copy link

Description

The following code:

<?php
date_default_timezone_set('UTC');

$dto = date_create("2006-12-12");

if ($dto instanceof DateTime) {
    var_dump(date_isodate_set($dto, PHP_INT_MAX, 100, 15));
    var_dump($dto->format("Y/m/d H:i:s"));
} else {
    echo "Failed to create DateTime object.\n";
}

Resulted in this output:

/nightly_php/php-src/ext/date/php_date.c:39:75: runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself

But I expected this output instead:

PHP Version

nightly

Operating System

ubuntu 22.04

@devnexen
Copy link
Member

devnexen commented Apr 24, 2025

php_llabs like llabs is unsafe against LLONG_MIN dunno it should return LLONG_MAX, or handling error.

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

3 participants