php integer overflow not working

Web hosting, MySQL, PHP and all that good stuff.

Moderator: Lillian.W@AST

Post Reply
davlee
Posts: 11
youtube meble na wymiar Warszawa
Joined: Fri Jul 11, 2014 11:48 pm

php integer overflow not working

Post by davlee »

I am having problems running a php program on my Asustor 302T box which runs fine on my Windows box.

I traced the problem down to a line of code:

$higherValue = 0xFFFFFFFF;

This should be an maximum unsigned int value of 4294967295, but PHP doesn't handle unsigned int so it should convert it to a float when it overflows an int. This is not happening on my Asustor. Instead it is just converting it to a max int value of 2147483647.

I wrote a small php test script:

var_dump(0x00000000);
var_dump(0xFFFFFFFF);
var_dump(0xFFFFFFFE);

On Windows:

int(0)
float(4294967295)
float(4294967294)

On Asustor Linux:

int(0)
int(2147483647) << no overflow to float
int(2147483647) << no overflow to float

Versions:

Windows:

>.\win32\php -c php-win.ini -v
PHP 5.3.15 (cli) (built: Jul 20 2012 00:20:38)
Copyright © 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright © 1998-2012 Zend Technologies

Asustor Linux:
> php -v
PHP 5.3.27 (cli) (built: Jun 24 2014 01:48:44)
Copyright © 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright © 1998-2013 Zend Technologies

How do I get integer overflow working? Do I have a bad build of PHP?
Post Reply

Return to “Web Hosting”