It is currently Thu Jan 21, 2021 1:31 am
All times are UTC + 8 hours

php integer overflow not working

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

php integer overflow not working

Postby davlee » Sat Jul 12, 2014 8:01 am

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?
davlee
 
Posts: 11
Joined: Fri Jul 11, 2014 11:48 pm

Return to Web Hosting

  • You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum
    You cannot post attachments in this forum
  • Who is online

    Users browsing this forum: No registered users and 1 guest