php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60052 Integer returned as a 64bit integer on X64_86
Submitted: 2011-10-13 13:01 UTC Modified: 2014-01-01 12:41 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: m dot vanduren at jonker dot nl Assigned: mariuz
Status: Assigned Package: PDO Firebird
PHP Version: 5.3.8 OS: All (linux tested)
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-10-13 13:01 UTC] m dot vanduren at jonker dot nl
Description:
------------
Integer on firebird is treated as a 32 bit int and int64 is used as a 64 bit integer.
In the pdo_firebird driver INT64 is not implemented and LONG (int32) is treated as a long integer. On an x86_64 machine this means that a SQL_LONG doesn't honor the bit-sign in a value and INT64 doesn't return anything.

This patch should fix this value for x86_64 systems while leaving x86 systems unchanged.

Test script:
---------------
any firebirdSQL database with a integer field containing a negative value.
retrieve the value with the pdo_firebird driver on a 64 bit machine and echo it to the screen.

Expected result:
----------------
negative values with integer and should be returned as a negative number.

Actual result:
--------------
negative values are returned as their unsigned counterpart.

Patches

php5-bug60052.patch (last revision 2013-09-26 06:21 UTC) by slavb18 at gmail dot com)
integer_x86_64.patch (last revision 2011-10-13 13:03 UTC) by m dot vanduren at jonker dot nl)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-16 00:36 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: felipe
 [2011-12-28 15:48 UTC] mariuz@php.net
-Package: InterBase related +Package: PDO related -Assigned To: felipe +Assigned To: mariuz
 [2012-04-02 14:04 UTC] mariuz@php.net
LL_MASK it should be already be "l" see the php_pdo_firebird_int.h:# define 
LL_MASK "l"

So in the in the slprintf 
slprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata);
should be replaced with 

slprintf(*ptr, CHAR_BUF_LEN, "%" "l" "d", *(ISC_INT64*)var->sqldata);

I will check and create a test for 5.3.x
 [2013-09-25 18:22 UTC] slavb18 at gmail dot com
why this patch only partially accepted? still not working on x86-64
$q="select * FROM RDB\$DATABASE";
$q="execute block
returns (
rI integer)
as
begin
rI= -1;
suspend;
end";
$res=$pdo->dbExecute($q);
print_r($res->fetch());

outputs
Array
(
    [RI] => 4294967295
    [0] => 4294967295
)
istead of
Array
(
    [RI] => -1
    [0] => -1
)
 [2013-10-07 08:51 UTC] mariuz@php.net
I will recheck and apply it (the patch)
 [2014-01-01 12:41 UTC] felipe@php.net
-Package: PDO related +Package: PDO Firebird
 [2014-01-03 02:40 UTC] papatiger+phpbug at gmail dot com
Why are many serious bugs of pdo.firebird not revised?
I cannot use ORM such as DBAL in Firebird.
 [2014-01-15 06:58 UTC] slavb18 at gmail dot com
may be it's time to move to Java with native POJO ? )
 [2014-01-15 06:59 UTC] slavb18 at gmail dot com
bug and patch are three years old, looks like this is not need to anybody
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 08:02:33 2014 UTC