php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41237 XOR problem
Submitted: 2007-04-30 09:15 UTC Modified: 2008-09-20 19:48 UTC
Votes:6
Avg. Score:4.2 ± 0.9
Reproduced:5 of 5 (100.0%)
Same Version:0 (0.0%)
Same OS:4 (80.0%)
From: victorepand at gmail dot com Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.2.1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: victorepand at gmail dot com
New email:
PHP Version: OS:

 

 [2007-04-30 09:15 UTC] victorepand at gmail dot com
Description:
------------
I am finding a difference between the same bitwise arithmetic from one server to the next when using PHP. What's more, this bitwise arithmetic is necessary for the PHP script to run, so as a result it will only function on one server, but not the other.

Here is an example I am using to demonstrate this:

if ((43814 ^ -4738698913)!=-443704711) print "incorrect result";
else print "correct result";

The (^) operator is an XOR bitwise arithmetic function as shown here:
http://us2.php.net/manual/en/language.operators.bitwise.php
and I am required to use numbers like the ones shown.

On one server, I have tried both PHP 4.4.0 and PHP 5.1.0RC1 and the math works correctly for both (the correct answer as shown above is -443704711). But on another server, I have tried the same math with both PHP 4.4.6 and PHP 5.2.1, and it does not work correctly with either version of PHP! The result I get at that server is: -2147439834.

I have no idea what could be the problem, but I can show you the PHP Info for both servers and perhaps you can detect what might be the difference?

Here is the PHP Info for the server that works correctly using PHP 5.1.0RC1:
http://www.buycellularphones.info/cron/special/info.php

Here is the PHP Info for the other server using PHP 5.2.1 that does not work correctly:
http://www.customdesignpostcards.com/cron/special/info.php


Reproduce code:
---------------
if ((43814 ^ -4738698913)!=-443704711) print "incorrect result";
else print "correct result";

Expected result:
----------------
correct result

Actual result:
--------------
incorrect result

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-30 13:09 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2007-05-08 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-08-29 09:22 UTC] php dot ydyoda at spamgourmet dot com
For information:

Same bug on PHP 4.3.11
But no probleme with PHP 4.3.5
 [2008-02-29 21:53 UTC] dochoncho at gmail dot com
Reproduced using PHP/5.2.3-1ubuntu6.3

What fun.
 [2008-09-20 18:33 UTC] lombard-marc at wanadoo dot fr
Same bug happens on my production server PHP 5.2.0-8 on Linux
It is ok on the development server PHP 5.2.6 on Windows.
Impacts blowfish algorithms (2 servers get different results)
 [2008-09-20 19:48 UTC] pajoye@php.net
-4738698913 is out of range of a 32bits signed integer. PHP integer range is 32bits, it is not safe to rely on 64bit support.

By the way, if you like to have the blowfish crypt, it is now enabled by default in 5.3.0 (development phase but still :).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 14:01:30 2024 UTC